Skip to content

Commit 985af4a

Browse files
Merge pull request #135 from BenWiederhake/dev-complete-visibility
Make 'complete' available to procmacro's output by conversion to module
2 parents 48aae19 + bbb193d commit 985af4a

File tree

14 files changed

+38
-41
lines changed

14 files changed

+38
-41
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ repository = "https://github.com/uutils/uutils-args"
1010
readme = "README.md"
1111

1212
[dependencies]
13-
uutils-args-derive = { version = "0.1.0", path = "derive" }
14-
uutils-args-complete = { version = "0.1.0", path = "complete" }
15-
strsim = "0.11.1"
1613
lexopt = "0.3.0"
14+
roff = "0.2.1"
15+
strsim = "0.11.1"
16+
uutils-args-derive = { version = "0.1.0", path = "derive" }
1717

1818
[features]
1919
parse-is-complete = []
2020

2121
[workspace]
22-
members = ["derive", "complete"]
22+
members = ["derive"]

complete/Cargo.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

complete/LICENSE

Lines changed: 0 additions & 1 deletion
This file was deleted.

derive/src/complete.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
4949
.map(|Flag { flag, value }| {
5050
let flag = flag.to_string();
5151
let value = match value {
52-
Value::No => quote!(::uutils_args_complete::Value::No),
53-
Value::Optional(name) => quote!(::uutils_args_complete::Value::Optional(#name)),
54-
Value::Required(name) => quote!(::uutils_args_complete::Value::Required(#name)),
52+
Value::No => quote!(::uutils_args::complete::Value::No),
53+
Value::Optional(name) => {
54+
quote!(::uutils_args::complete::Value::Optional(#name))
55+
}
56+
Value::Required(name) => {
57+
quote!(::uutils_args::complete::Value::Required(#name))
58+
}
5559
};
56-
quote!(::uutils_args_complete::Flag {
60+
quote!(::uutils_args::complete::Flag {
5761
flag: #flag,
5862
value: #value
5963
})
@@ -64,11 +68,15 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
6468
.iter()
6569
.map(|Flag { flag, value }| {
6670
let value = match value {
67-
Value::No => quote!(::uutils_args_complete::Value::No),
68-
Value::Optional(name) => quote!(::uutils_args_complete::Value::Optional(#name)),
69-
Value::Required(name) => quote!(::uutils_args_complete::Value::Required(#name)),
71+
Value::No => quote!(::uutils_args::complete::Value::No),
72+
Value::Optional(name) => {
73+
quote!(::uutils_args::complete::Value::Optional(#name))
74+
}
75+
Value::Required(name) => {
76+
quote!(::uutils_args::complete::Value::Required(#name))
77+
}
7078
};
71-
quote!(::uutils_args_complete::Flag {
79+
quote!(::uutils_args::complete::Flag {
7280
flag: #flag,
7381
value: #value
7482
})
@@ -81,7 +89,7 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
8189
};
8290

8391
arg_specs.push(quote!(
84-
::uutils_args_complete::Arg {
92+
::uutils_args::complete::Arg {
8593
short: vec![#(#short),*],
8694
long: vec![#(#long),*],
8795
help: #help,
@@ -90,7 +98,7 @@ pub fn complete(args: &[Argument], file: &Option<String>) -> TokenStream {
9098
))
9199
}
92100

93-
quote!(::uutils_args_complete::Command {
101+
quote!(::uutils_args::complete::Command {
94102
name: option_env!("CARGO_BIN_NAME").unwrap_or(env!("CARGO_PKG_NAME")),
95103
summary: #summary,
96104
after_options: #after_options,

derive/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn arguments(input: TokenStream) -> TokenStream {
117117
#version_string
118118
}
119119

120-
fn complete() -> ::uutils_args_complete::Command<'static> {
120+
fn complete() -> ::uutils_args::complete::Command<'static> {
121121
use ::uutils_args::Value;
122122
#complete_command
123123
}
@@ -212,9 +212,9 @@ pub fn value(input: TokenStream) -> TokenStream {
212212
})
213213
}
214214

215-
fn value_hint() -> ::uutils_args_complete::ValueHint {
215+
fn value_hint() -> ::uutils_args::complete::ValueHint {
216216
let keys: [&str; #keys_len] = [#(#all_keys),*];
217-
::uutils_args_complete::ValueHint::Strings(
217+
::uutils_args::complete::ValueHint::Strings(
218218
keys
219219
.into_iter()
220220
.map(ToString::to_string)

complete/src/bash.rs renamed to src/complete/bash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For the full copyright and license information, please view the LICENSE
22
// file that was distributed with this source code.
33

4-
use crate::{Command, Flag};
4+
use crate::complete::{Command, Flag};
55

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

4040
#[test]
4141
fn simple() {

complete/src/fish.rs renamed to src/complete/fish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For the full copyright and license information, please view the LICENSE
22
// file that was distributed with this source code.
33

4-
use crate::{Command, Flag, ValueHint};
4+
use crate::complete::{Command, Flag, ValueHint};
55

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

5050
#[test]
5151
fn short() {

complete/src/man.rs renamed to src/complete/man.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For the full copyright and license information, please view the LICENSE
22
// file that was distributed with this source code.
33

4-
use crate::{Command, Flag, Value};
4+
use crate::complete::{Command, Flag, Value};
55
use roff::{Roff, bold, italic, roman};
66

77
pub fn render(c: &Command) -> String {

complete/src/md.rs renamed to src/complete/md.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For the full copyright and license information, please view the LICENSE
22
// file that was distributed with this source code.
33

4-
use crate::{Command, Flag, Value};
4+
use crate::complete::{Command, Flag, Value};
55

66
/// Render command to a markdown file for mdbook
77
pub fn render(c: &Command) -> String {
File renamed without changes.

0 commit comments

Comments
 (0)