Skip to content

Commit

Permalink
suppaftp as workspace; cli-bin as independent pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Oct 8, 2022
1 parent 61872d9 commit 77ca09b
Show file tree
Hide file tree
Showing 27 changed files with 185 additions and 120 deletions.
1 change: 1 addition & 0 deletions .github/actions-rs/grcov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ignore:
- "/*"
- "C:/*"
- "../*"
- "suppaftp-cli/*"
35 changes: 15 additions & 20 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,65 @@ env:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup containers
run: docker-compose -f "tests/docker-compose.yml" up -d --build
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Setup containers
run: docker-compose -f "tests/docker-compose.yml" up -d --build
- name: Build simple
uses: actions-rs/cargo@v1
with:
command: build
args: --package suppaftp
- name: Build secure (native-tls)
uses: actions-rs/cargo@v1
with:
command: build
args: --features native-tls,deprecated
args: --features native-tls,deprecated --package suppaftp
- name: Build secure (rustls)
uses: actions-rs/cargo@v1
with:
command: build
args: --features rustls,deprecated
args: --features rustls,deprecated --package suppaftp
- name: Build async
uses: actions-rs/cargo@v1
with:
command: build
args: --features async,deprecated
args: --features async,deprecated --package suppaftp
- name: Build async-native-tls
uses: actions-rs/cargo@v1
with:
command: build
args: --features async-native-tls,deprecated
- name: Build suppaftp-cli
uses: actions-rs/cargo@v1
with:
command: build
args: --features native-tls --features cli-bin --bin suppaftp
args: --features async-native-tls,deprecated --package suppaftp
- name: Run tests (native-tls)
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --no-default-features --features native-tls,async-native-tls,with-containers --no-fail-fast
args: --lib --package suppaftp --no-default-features --features native-tls,async-native-tls,with-containers --no-fail-fast
env:
RUST_LOG: trace
- name: Run tests (rustls)
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --no-default-features --features rustls,async-rustls,with-containers --no-fail-fast
args: --lib --package suppaftp --no-default-features --features rustls,async-rustls,with-containers --no-fail-fast
env:
RUST_LOG: trace
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --features deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features deprecated -- -Dwarnings
- name: Clippy (async)
run: cargo clippy --features async,deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features async,deprecated -- -Dwarnings
- name: Clippy (native-tls)
run: cargo clippy --features native-tls,deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features native-tls,deprecated -- -Dwarnings
- name: Clippy (async-native-tls)
run: cargo clippy --features async-native-tls,deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features async-native-tls,deprecated -- -Dwarnings
- name: Clippy (rustls)
run: cargo clippy --features rustls,deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features rustls,deprecated -- -Dwarnings
- name: Clippy (async-rustls)
run: cargo clippy --features async-rustls,deprecated -- -Dwarnings
run: cargo clippy --package suppaftp --features async-rustls,deprecated -- -Dwarnings
29 changes: 29 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: cli-bin

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./suppaftp-cli
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --package suppaftp-cli
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --package suppaftp-cli -- -Dwarnings
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Released on 08/10/2022

- Added `native-tls-vendored` and `async-native-tls-vendored` features to link OpenSSL statically
- suppaftp-cli as a separate package.
- Rustls support
- **‼️ BREAKING CHANGE**: refactored secure features:
- **REMOVED** `secure`/`async-secure` feature
Expand Down
80 changes: 5 additions & 75 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,75 +1,5 @@
[package]
name = "suppaftp"
version = "4.5.0"
authors = ["Christian Visintin <christian.visintin1997@gmail.com>", "Matt McCoy <mattnenterprise@yahoo.com>"]
edition = "2021"
documentation = "https://docs.rs/suppaftp/"
repository = "/~https://github.com/veeso/suppaftp"
description = "A super FTP/FTPS client library for Rust"
include = ["src/**/*", "cli/**/*", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "CHANGELOG.md"]
readme = "README.md"
license = "Apache-2.0/MIT"
keywords = ["ftp", "ftps", "network-protocol", "async"]
categories = ["asynchronous", "network-programming"]

[lib]
name = "suppaftp"
path = "src/lib.rs"

[[bin]]
name = "suppaftp"
path = "cli/main.rs"
required-features = ["secure", "cli-bin"]

[dependencies]
chrono = "^0.4"
lazy-regex = "^2.3"
log = "^0.4"
thiserror = "^1"
# async
async-std = { version = "^1.10", optional = true }
async-native-tls-crate = { package = "async-native-tls", version = "^0.4", optional = true }
async-tls = { version = "^0.11", optional = true }
pin-project = { version = "^1", optional = true }
# secure
native-tls-crate = { package = "native-tls", version = "^0.2", optional = true }
rustls-crate = { package = "rustls", version = "^0.20", optional = true }
# cli-bin
env_logger = { version = "^0.9", optional = true }
rpassword = { version = "5.0.1", optional = true }

[dev-dependencies]
async-attributes = "1.1.2"
env_logger = "^0.9.0"
pretty_assertions = "^1.0.0"
rand = "^0.8.4"
serial_test = "^0.8.0"
webpki-roots = "0.22.5"

[features]
# Enable async support for suppaftp
async = ["async-std", "pin-project"]
async-default-tls = [ "async-native-tls" ]
async-native-tls = [ "async-native-tls-crate", "async-secure" ]
async-rustls = [ "async-tls", "async-secure" ]
async-secure = [ "async" ]

# Enable deprecated FTP/FTPS methods
deprecated = []

# Enable support for FTPS which requires native-tls (openssl is required on Linux) or RustTLS
default-tls = [ "native-tls" ]
native-tls = [ "native-tls-crate", "secure" ]
native-tls-vendored = [ "native-tls", "native-tls-crate/vendored" ]
async-native-tls-vendored = [ "async-native-tls", "async-native-tls-crate/vendored" ]
rustls = [ "rustls-crate", "secure" ]
secure = []

# Disable logging
no-log = [ "log/max_level_off" ]

# Must be enabled whenever testing with docker containers
with-containers = []

# Don't enable this feature; is used by suppaftp binary only
cli-bin = [ "env_logger", "rpassword"]
[workspace]
members = [
"suppaftp",
"suppaftp-cli"
]
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
<a href="/~https://github.com/veeso/suppaftp/actions"
><img
src="/~https://github.com/veeso/suppaftp/workflows/Build/badge.svg"
alt="Linux CI"
alt="Lib-CI"
/></a>
<a href="/~https://github.com/veeso/suppaftp/actions"
><img
src="/~https://github.com/veeso/suppaftp/workflows/cli-bin/badge.svg"
alt="Cli-bin-ci"
/></a>
<a href="https://coveralls.io/github/veeso/suppaftp"
><img
Expand Down Expand Up @@ -255,7 +260,8 @@ SuppaFTP comes also with a built-in command-line FTP client. This CLI applicatio
You can simply install as any other rust application via **Cargo**:

```sh
cargo install suppaftp --features="secure cli-bin"
cargo install suppaftp-cli
suppaftp --version
```

---
Expand Down
24 changes: 24 additions & 0 deletions suppaftp-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
authors = ["Christian Visintin <christian.visintin1997@gmail.com>"]
categories = ["command-line-utilities"]
description = "FTP command line client, based on suppaftp"
edition = "2021"
homepage = "/~https://github.com/veeso/suppaftp"
include = ["src/**/*", "../LICENSE", "../README.md", "../CHANGELOG.md"]
keywords = ["ftp", "ftp-client", "suppaftp"]
license = "MIT"
name = "suppaftp-cli"
readme = "../README.md"
repository = "/~https://github.com/veeso/suppaftp"
version = "4.5.0"

[[bin]]
name = "suppaftp"
path = "src/main.rs"

[dependencies]
argh = "^0.1"
env_logger = "^0.9"
log = "^0.4"
rpassword = "^5"
suppaftp = { path = "../suppaftp", version = "^4.5", features = [ "native-tls" ] }
File renamed without changes.
15 changes: 15 additions & 0 deletions suppaftp-cli/src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use argh::FromArgs;

#[derive(FromArgs)]
#[argh(
description = "Please, report issues to </~https://github.com/veeso/suppaftp>
Please, consider supporting the author <https://ko-fi.com/veeso>"
)]
pub struct Args {
#[argh(switch, short = 'D', description = "enable TRACE log level")]
pub debug: bool,
#[argh(switch, short = 'v', description = "verbose mode")]
pub verbose: bool,
#[argh(switch, short = 'V', description = "print version")]
pub version: bool,
}
File renamed without changes.
44 changes: 22 additions & 22 deletions cli/main.rs → suppaftp-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@
//! This is a client you can install via `cargo install suppaftp` on your system to connect and work with FTP servers
//!
const SUPPAFTP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
const SUPPAFTP_VERSION: &str = env!("CARGO_PKG_VERSION");

// -- mods
mod actions;
mod args;
mod command;

use actions::*;
use args::Args;
use command::Command;
// -- locals

use suppaftp::{FtpError, FtpStream};
// -- ext
use std::env;
use env_logger::Builder as LogBuilder;
use log::LevelFilter;
use std::io;
use std::io::Write;
use std::process::exit;
use std::str::FromStr;
use suppaftp::{FtpError, FtpStream};

const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
const APP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");

fn usage() {
println!(
"suppaftp {} ~ Developed by {}",
SUPPAFTP_VERSION, SUPPAFTP_AUTHORS
);
println!();
println!("Available commands:");
println!("APPE <file> <dest> Append content of local file `file` to `dest`");
println!("CDUP Go to parent directory");
Expand All @@ -47,10 +43,6 @@ fn usage() {
println!("RM <file> Remove file");
println!("RMDIR <dir> Remove directory");
println!("SIZE <file> Get `file` size");
println!();
println!("Please, report issues to </~https://github.com/veeso/suppaftp>");
println!("Please, consider supporting the author <https://ko-fi.com/veeso>");
println!();
}

fn input() -> Command {
Expand All @@ -70,13 +62,21 @@ fn input() -> Command {
}

fn main() {
let args: Vec<String> = env::args().collect();
if let Some("-h") = args.get(1).map(|x| x.as_str()) {
usage();
exit(255);
let args: Args = argh::from_env();
// print version
if args.version {
println!("suppaftp {} - developed by {}", APP_VERSION, APP_AUTHORS)
}
// init logger
env_logger::init();
LogBuilder::new()
.filter_level(if args.debug {
LevelFilter::Debug
} else if args.verbose {
LevelFilter::Info
} else {
LevelFilter::Off
})
.init();
// Main loop
let mut ftp: Option<FtpStream> = None;
loop {
Expand Down
Loading

0 comments on commit 77ca09b

Please sign in to comment.