1
1
//! Command line interface, built using [`crate::clap` with `Derive`](https://docs.rs/clap/latest/clap/_derive/_tutorial/index.html)
2
- use clap:: { ArgGroup , Parser , Subcommand } ;
2
+ use clap:: { ArgGroup , Args , Parser , Subcommand } ;
3
3
4
4
use super :: hashing:: { AaLevel , HashType , DEFAULT_LEVEL } ;
5
5
@@ -40,7 +40,7 @@ pub fn check_threads(threads: usize) {
40
40
#[ derive( Parser ) ]
41
41
#[ command( author, version, about, long_about = None ) ]
42
42
#[ command( propagate_version = true ) ]
43
- pub struct Args {
43
+ pub struct MainArgs {
44
44
#[ doc( hidden) ]
45
45
#[ command( subcommand) ]
46
46
pub command : Commands ,
@@ -54,6 +54,18 @@ pub struct Args {
54
54
pub quiet : bool ,
55
55
}
56
56
57
+ #[ derive( Args ) ]
58
+ #[ group( required = true , multiple = false ) ]
59
+ pub struct Kmers {
60
+ /// K-mer list (comma separated k-mer values to sketch at)
61
+ #[ arg( short, long, required = true , value_delimiter = ',' ) ]
62
+ pub k_vals : Option < Vec < usize > > ,
63
+
64
+ /// K-mer linear sequence (start,end,step)
65
+ #[ arg( long, required = true , value_delimiter = ',' ) ]
66
+ pub k_seq : Option < Vec < usize > > ,
67
+ }
68
+
57
69
/// Subcommands and their specific options
58
70
#[ derive( Subcommand ) ]
59
71
pub enum Commands {
@@ -65,10 +77,10 @@ pub enum Commands {
65
77
/// Create sketches from input data
66
78
Sketch {
67
79
/// List of input FASTA files
68
- #[ arg( long , group = "input" , num_args = 1 .. , value_delimiter = ',' ) ]
80
+ #[ arg( group = "input" ) ]
69
81
seq_files : Option < Vec < String > > ,
70
82
71
- /// File listing input files (tab separated name, sequences)
83
+ /// File listing input files (tab separated name, sequences, see README )
72
84
#[ arg( short, group = "input" ) ]
73
85
file_list : Option < String > ,
74
86
@@ -86,13 +98,8 @@ pub enum Commands {
86
98
#[ arg( short) ]
87
99
output : String ,
88
100
89
- /// K-mer list
90
- #[ arg( short, long, group = "kmer" , required = true , num_args = 1 .., value_delimiter = ',' ) ]
91
- k_vals : Option < Vec < usize > > ,
92
-
93
- /// K-mer sequence: start end step
94
- #[ arg( long, group = "kmer" , required = true , num_args = 3 ) ]
95
- k_seq : Option < Vec < usize > > ,
101
+ #[ command( flatten) ]
102
+ kmers : Kmers ,
96
103
97
104
/// Sketch size
98
105
#[ arg( short, long, default_value_t = DEFAULT_SKETCHSIZE ) ]
@@ -240,7 +247,7 @@ pub enum Commands {
240
247
} ,
241
248
}
242
249
243
- /// Function to parse command line args into [`Args `] struct
244
- pub fn cli_args ( ) -> Args {
245
- Args :: parse ( )
250
+ /// Function to parse command line args into [`MainArgs `] struct
251
+ pub fn cli_args ( ) -> MainArgs {
252
+ MainArgs :: parse ( )
246
253
}
0 commit comments