Skip to content

Commit

Permalink
make into nimble package
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Sep 14, 2022
1 parent 0625efb commit 37d6587
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: asyncftpclient

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

workflow_dispatch:

jobs:
compile_example:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: jiro4989/setup-nim-action@v1

- name: install package
run: nimble install -y

- name: compile example
run: nimble compileExample
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# asyncftpclient

FTP client implementation, originally part of the Nim standard library.

Install with `nimble install asyncftpclient` or add `requires "asyncftpclient"` to your package's `.nimble` file.
14 changes: 14 additions & 0 deletions asyncftpclient.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Package

version = "0.1.0"
author = "nim-lang"
description = "FTP client implementation (originally in the stdlib)."
license = "MIT"
srcDir = "src"

# Dependencies

requires "nim >= 0.15.0"

task compileExample, "compiles client example":
exec "nim c examples/client_example"
17 changes: 17 additions & 0 deletions examples/client_example.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import asyncftpclient, asyncdispatch

var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
proc main(ftp: AsyncFtpClient) {.async.} =
await ftp.connect()
echo await ftp.pwd()
echo await ftp.listDirs()
await ftp.store("payload.jpg", "payload.jpg")
await ftp.retrFile("payload.jpg", "payload2.jpg")
await ftp.rename("payload.jpg", "payload_renamed.jpg")
await ftp.store("payload.jpg", "payload_remove.jpg")
await ftp.removeFile("payload_remove.jpg")
await ftp.createDir("deleteme")
await ftp.removeDir("deleteme")
echo("Finished")

waitFor main(ftp)
17 changes: 0 additions & 17 deletions src/asyncftpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,3 @@ proc newAsyncFtpClient*(address: string, port = Port(21),
result.progressInterval = progressInterval
result.dsockConnected = false
result.csock = newAsyncSocket()

when not defined(testing) and isMainModule:
var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
proc main(ftp: AsyncFtpClient) {.async.} =
await ftp.connect()
echo await ftp.pwd()
echo await ftp.listDirs()
await ftp.store("payload.jpg", "payload.jpg")
await ftp.retrFile("payload.jpg", "payload2.jpg")
await ftp.rename("payload.jpg", "payload_renamed.jpg")
await ftp.store("payload.jpg", "payload_remove.jpg")
await ftp.removeFile("payload_remove.jpg")
await ftp.createDir("deleteme")
await ftp.removeDir("deleteme")
echo("Finished")

waitFor main(ftp)

0 comments on commit 37d6587

Please sign in to comment.