11use std:: path:: PathBuf ;
22
3- use clap:: Parser ;
3+ use clap:: { Parser , ValueEnum } ;
44
55/// Generate Nix packages with hash prefetching, license detection, and more
66/// https://github.com/nix-community/nix-init
77#[ derive( Parser ) ]
8- #[ command( version , verbatim_doc_comment) ]
8+ #[ command( verbatim_doc_comment) ]
99pub struct Opts {
1010 /// The path or directory to output the generated file to
1111 pub output : Option < PathBuf > ,
@@ -14,6 +14,42 @@ pub struct Opts {
1414 #[ arg( short, long) ]
1515 pub url : Option < String > ,
1616
17+ /// Specify the tag or revision
18+ #[ arg( long) ]
19+ pub rev : Option < String > ,
20+
21+ /// Always fetch submodules when possible
22+ ///
23+ /// use --submodules=false to never fetch submodules
24+ #[ arg( short = 'S' , long, num_args=0 ..=1 , require_equals = true , default_missing_value = "true" ) ]
25+ pub submodules : Option < bool > ,
26+
27+ /// Specify the version of the package, or print nix-init version if no arguments are present
28+ #[ arg( short = 'V' , long) ]
29+ pub version : Option < Option < String > > ,
30+
31+ /// Specify the pname
32+ #[ arg( long) ]
33+ pub pname : Option < String > ,
34+
35+ /// Specify the builder
36+ #[ arg( long) ]
37+ pub builder : Option < BuilderFunction > ,
38+
39+ /// Specify how the cargo dependencies are vendored
40+ #[ arg( long) ]
41+ pub cargo_vendor : Option < CargoVendor > ,
42+
43+ /// Always overwrite files
44+ ///
45+ /// use --overwrite=false to never overwrite files
46+ #[ arg( short = 'y' , long, num_args=0 ..=1 , require_equals = true , default_missing_value = "true" ) ]
47+ pub overwrite : Option < bool > ,
48+
49+ /// Don't prompt for anything (requires --url)
50+ #[ arg( long) ]
51+ pub headless : bool ,
52+
1753 /// Path to nixpkgs (in nix)
1854 ///
1955 /// Examples:
@@ -33,3 +69,25 @@ pub struct Opts {
3369 #[ arg( short, long) ]
3470 pub config : Option < PathBuf > ,
3571}
72+
73+ #[ derive( Clone , ValueEnum ) ]
74+ #[ clap( rename_all = "camelCase" ) ]
75+ pub enum BuilderFunction {
76+ BuildGoModule ,
77+ BuildPythonApplication ,
78+ BuildPythonPackage ,
79+ BuildRustPackage ,
80+ MkDerivation ,
81+ }
82+
83+ #[ derive( Clone , Copy , ValueEnum ) ]
84+ #[ clap( rename_all = "camelCase" ) ]
85+ #[ cfg_attr(
86+ not_build,
87+ derive( parse_display:: Display ) ,
88+ display( style = "camelCase" )
89+ ) ]
90+ pub enum CargoVendor {
91+ FetchCargoVendor ,
92+ ImportCargoLock ,
93+ }
0 commit comments