Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ repository = "https://github.com/uutils/uutils-args"
readme = "README.md"

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

[features]
parse-is-complete = []

[workspace]
members = ["derive", "complete"]
members = ["derive"]
11 changes: 0 additions & 11 deletions complete/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion complete/LICENSE

This file was deleted.

28 changes: 18 additions & 10 deletions derive/src/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
.map(|Flag { flag, value }| {
let flag = flag.to_string();
let value = match value {
Value::No => quote!(::uutils_args_complete::Value::No),
Value::Optional(name) => quote!(::uutils_args_complete::Value::Optional(#name)),
Value::Required(name) => quote!(::uutils_args_complete::Value::Required(#name)),
Value::No => quote!(::uutils_args::complete::Value::No),
Value::Optional(name) => {
quote!(::uutils_args::complete::Value::Optional(#name))
}
Value::Required(name) => {
quote!(::uutils_args::complete::Value::Required(#name))
}
};
quote!(::uutils_args_complete::Flag {
quote!(::uutils_args::complete::Flag {
flag: #flag,
value: #value
})
Expand All @@ -64,11 +68,15 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
.iter()
.map(|Flag { flag, value }| {
let value = match value {
Value::No => quote!(::uutils_args_complete::Value::No),
Value::Optional(name) => quote!(::uutils_args_complete::Value::Optional(#name)),
Value::Required(name) => quote!(::uutils_args_complete::Value::Required(#name)),
Value::No => quote!(::uutils_args::complete::Value::No),
Value::Optional(name) => {
quote!(::uutils_args::complete::Value::Optional(#name))
}
Value::Required(name) => {
quote!(::uutils_args::complete::Value::Required(#name))
}
};
quote!(::uutils_args_complete::Flag {
quote!(::uutils_args::complete::Flag {
flag: #flag,
value: #value
})
Expand All @@ -81,7 +89,7 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
};

arg_specs.push(quote!(
::uutils_args_complete::Arg {
::uutils_args::complete::Arg {
short: vec![#(#short),*],
long: vec![#(#long),*],
help: #help,
Expand All @@ -90,7 +98,7 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
))
}

quote!(::uutils_args_complete::Command {
quote!(::uutils_args::complete::Command {
name: option_env!("CARGO_BIN_NAME").unwrap_or(env!("CARGO_PKG_NAME")),
summary: #summary,
after_options: #after_options,
Expand Down
6 changes: 3 additions & 3 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn arguments(input: TokenStream) -> TokenStream {
#version_string
}

fn complete() -> ::uutils_args_complete::Command<'static> {
fn complete() -> ::uutils_args::complete::Command<'static> {
use ::uutils_args::Value;
#complete_command
}
Expand Down Expand Up @@ -212,9 +212,9 @@ pub fn value(input: TokenStream) -> TokenStream {
})
}

fn value_hint() -> ::uutils_args_complete::ValueHint {
fn value_hint() -> ::uutils_args::complete::ValueHint {
let keys: [&str; #keys_len] = [#(#all_keys),*];
::uutils_args_complete::ValueHint::Strings(
::uutils_args::complete::ValueHint::Strings(
keys
.into_iter()
.map(ToString::to_string)
Expand Down
4 changes: 2 additions & 2 deletions complete/src/bash.rs → src/complete/bash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Command, Flag};
use crate::complete::{Command, Flag};

/// Create completion script for `bash`
///
Expand Down Expand Up @@ -35,7 +35,7 @@ pub fn render(c: &Command) -> String {
#[cfg(test)]
mod test {
use super::render;
use crate::{Arg, Command, Flag, Value};
use crate::complete::{Arg, Command, Flag, Value};

#[test]
fn simple() {
Expand Down
4 changes: 2 additions & 2 deletions complete/src/fish.rs → src/complete/fish.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Command, Flag, ValueHint};
use crate::complete::{Command, Flag, ValueHint};

/// Create completion script for `fish`
///
Expand Down Expand Up @@ -45,7 +45,7 @@ fn render_value_hint(value: &ValueHint) -> String {
#[cfg(test)]
mod test {
use super::render;
use crate::{Arg, Command, Flag, Value, ValueHint};
use crate::complete::{Arg, Command, Flag, Value, ValueHint};

#[test]
fn short() {
Expand Down
2 changes: 1 addition & 1 deletion complete/src/man.rs → src/complete/man.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Command, Flag, Value};
use crate::complete::{Command, Flag, Value};
use roff::{Roff, bold, italic, roman};

pub fn render(c: &Command) -> String {
Expand Down
2 changes: 1 addition & 1 deletion complete/src/md.rs → src/complete/md.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Command, Flag, Value};
use crate::complete::{Command, Flag, Value};

/// Render command to a markdown file for mdbook
pub fn render(c: &Command) -> String {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion complete/src/nu.rs → src/complete/nu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Arg, Command, Flag, Value, ValueHint};
use crate::complete::{Arg, Command, Flag, Value, ValueHint};
use std::fmt::Write;

/// Create completion script for `nushell`
Expand Down
2 changes: 1 addition & 1 deletion complete/src/zsh.rs → src/complete/zsh.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::{Arg, Command, Flag, Value, ValueHint};
use crate::complete::{Arg, Command, Flag, Value, ValueHint};

/// Create completion script for `zsh`
pub fn render(c: &Command) -> String {
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//!
#![doc = include_str!("../README.md")]

pub mod complete;
mod error;
pub mod internal;
pub mod positional;
Expand Down Expand Up @@ -103,7 +104,7 @@ pub trait Arguments: Sized {
Ok(())
}

fn complete() -> uutils_args_complete::Command<'static>;
fn complete() -> complete::Command<'static>;
}

/// An iterator over arguments.
Expand Down Expand Up @@ -197,7 +198,7 @@ pub trait Options<Arg: Arguments>: Sized {
}

fn complete(shell: &str) -> String {
uutils_args_complete::render(&Arg::complete(), shell)
complete::render(&Arg::complete(), shell)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/value.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::complete::ValueHint;
use crate::error::{Error, ErrorKind};
use std::{
ffi::{OsStr, OsString},
path::PathBuf,
};
use uutils_args_complete::ValueHint;

pub type ValueResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;

Expand Down Expand Up @@ -95,7 +95,7 @@ where
Ok(Some(T::from_value(value)?))
}

fn value_hint() -> uutils_args_complete::ValueHint {
fn value_hint() -> ValueHint {
T::value_hint()
}
}
Expand Down