@@ -52,7 +52,6 @@ use anyhow::Context as _;
52
52
53
53
use crate :: dump_usage:: dump_full_usage_for_readme;
54
54
use build:: Build ;
55
- use clap:: Parser as _;
56
55
use install:: Install ;
57
56
use show:: Show ;
58
57
@@ -93,47 +92,9 @@ macro_rules! user_output {
93
92
}
94
93
}
95
94
96
- fn main ( ) {
97
- #[ cfg( debug_assertions) ]
98
- std:: env:: set_var ( "RUST_BACKTRACE" , "1" ) ;
99
-
100
- env_logger:: builder ( ) . init ( ) ;
101
-
102
- if let Err ( error) = run ( ) {
103
- log:: error!( "{error:?}" ) ;
104
-
105
- #[ expect(
106
- clippy:: print_stderr,
107
- reason = "Our central place for outputting error messages"
108
- ) ]
109
- {
110
- eprintln ! ( "Error: {error}" ) ;
111
-
112
- // `clippy::exit` seems to be a false positive in `main()`.
113
- // See: https://github.com/rust-lang/rust-clippy/issues/13518
114
- #[ expect( clippy:: restriction, reason = "Our central place for safely exiting" ) ]
115
- std:: process:: exit ( 1 ) ;
116
- } ;
117
- }
118
- }
119
-
120
- /// Wrappable "main" to catch errors.
121
- fn run ( ) -> anyhow:: Result < ( ) > {
122
- let env_args = std:: env:: args ( )
123
- . filter ( |arg| {
124
- // Calling our `main()` with the cargo subcommand `cargo gpu` passes "gpu"
125
- // as the first parameter, so we want to ignore it.
126
- arg != "gpu"
127
- } )
128
- . collect :: < Vec < _ > > ( ) ;
129
- log:: trace!( "CLI args: {env_args:#?}" ) ;
130
- let cli = Cli :: parse_from ( & env_args) ;
131
- cli. command . run ( env_args)
132
- }
133
-
134
95
/// All of the available subcommands for `cargo gpu`
135
96
#[ derive( clap:: Subcommand ) ]
136
- enum Command {
97
+ pub enum Command {
137
98
/// Install rust-gpu compiler artifacts.
138
99
Install ( Box < Install > ) ,
139
100
@@ -191,13 +152,14 @@ impl Command {
191
152
/// the Cli struct representing the main cli
192
153
#[ derive( clap:: Parser ) ]
193
154
#[ clap( author, version, about, subcommand_required = true ) ]
194
- pub ( crate ) struct Cli {
155
+ pub struct Cli {
195
156
/// The command to run.
196
157
#[ clap( subcommand) ]
197
- command : Command ,
158
+ pub command : Command ,
198
159
}
199
160
200
- fn cache_dir ( ) -> anyhow:: Result < std:: path:: PathBuf > {
161
+ /// The central cache directory of cargo gpu
162
+ pub fn cache_dir ( ) -> anyhow:: Result < std:: path:: PathBuf > {
201
163
let dir = directories:: BaseDirs :: new ( )
202
164
. with_context ( || "could not find the user home directory" ) ?
203
165
. cache_dir ( )
0 commit comments