Skip to content

remove 'complete' feature flag, make it unconditional #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --features complete --workspace
- run: cargo test --workspace

rustfmt:
name: Rustfmt
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy check
run: cargo clippy --all-targets --features complete --workspace -- -D warnings
run: cargo clippy --all-targets --workspace -- -D warnings

docs:
name: Docs
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ readme = "README.md"

[dependencies]
uutils-args-derive = { version = "0.1.0", path = "derive" }
uutils-args-complete = { version = "0.1.0", path = "complete", optional = true }
uutils-args-complete = { version = "0.1.0", path = "complete" }
strsim = "0.11.1"
lexopt = "0.3.0"

[features]
parse-is-complete = ["complete"]
complete = ["uutils-args-complete"]
parse-is-complete = []

[workspace]
members = ["derive", "complete"]
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
check:
cargo fmt --all
cargo test --features complete
cargo clippy --all-targets --features complete --workspace -- -D warnings
cargo test
cargo clippy --all-targets --workspace -- -D warnings
cargo doc
2 changes: 0 additions & 2 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ pub fn arguments(input: TokenStream) -> TokenStream {
#version_string
}

#[cfg(feature = "complete")]
fn complete() -> ::uutils_args_complete::Command<'static> {
use ::uutils_args::Value;
#complete_command
Expand Down Expand Up @@ -212,7 +211,6 @@ pub fn value(input: TokenStream) -> TokenStream {
})
}

#[cfg(feature = "complete")]
fn value_hint() -> ::uutils_args_complete::ValueHint {
let keys: [&str; #keys_len] = [#(#all_keys),*];
::uutils_args_complete::ValueHint::Strings(
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The `[shell]` value here can be `fish`, `zsh`, `nu`, `sh`, `bash`, `csh`, `elvis

Additionally, the values `man` or `md` can be passed to generate man pages and markdown documentation (for `mdbook`).

If you do not want to hijack the [`Options::parse`](crate::Options::parse) function, you can instead enable the `complete` feature flag. This makes the `Options::complete` function available in addition to the [`Options::parse`](crate::Options::parse) function to generate a `String` with the completion.
If you do not want to hijack the [`Options::parse`](crate::Options::parse) function, you can instead use the `Options::complete` function available in addition to the [`Options::parse`](crate::Options::parse) function to generate a `String` with the completion.

<div class="chapters">

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pub trait Arguments: Sized {
Ok(())
}

#[cfg(feature = "complete")]
fn complete() -> uutils_args_complete::Command<'static>;
}

Expand Down Expand Up @@ -197,7 +196,6 @@ pub trait Options<Arg: Arguments>: Sized {
}
}

#[cfg(feature = "complete")]
fn complete(shell: &str) -> String {
uutils_args_complete::render(&Arg::complete(), shell)
}
Expand Down
4 changes: 0 additions & 4 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
ffi::{OsStr, OsString},
path::PathBuf,
};
#[cfg(feature = "complete")]
use uutils_args_complete::ValueHint;

pub type ValueResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
Expand Down Expand Up @@ -54,7 +53,6 @@ impl std::fmt::Display for ValueError {
pub trait Value: Sized {
fn from_value(value: &OsStr) -> ValueResult<Self>;

#[cfg(feature = "complete")]
fn value_hint() -> ValueHint {
ValueHint::Unknown
}
Expand All @@ -71,7 +69,6 @@ impl Value for PathBuf {
Ok(PathBuf::from(value))
}

#[cfg(feature = "complete")]
fn value_hint() -> ValueHint {
ValueHint::AnyPath
}
Expand All @@ -98,7 +95,6 @@ where
Ok(Some(T::from_value(value)?))
}

#[cfg(feature = "complete")]
fn value_hint() -> uutils_args_complete::ValueHint {
T::value_hint()
}
Expand Down