@@ -52,7 +52,6 @@ use anyhow::Context as _;
5252
5353use crate :: dump_usage:: dump_full_usage_for_readme;
5454use build:: Build ;
55- use clap:: Parser as _;
5655use install:: Install ;
5756use show:: Show ;
5857
@@ -93,47 +92,9 @@ macro_rules! user_output {
9392 }
9493}
9594
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-
13495/// All of the available subcommands for `cargo gpu`
13596#[ derive( clap:: Subcommand ) ]
136- enum Command {
97+ pub enum Command {
13798 /// Install rust-gpu compiler artifacts.
13899 Install ( Box < Install > ) ,
139100
@@ -191,13 +152,14 @@ impl Command {
191152/// the Cli struct representing the main cli
192153#[ derive( clap:: Parser ) ]
193154#[ clap( author, version, about, subcommand_required = true ) ]
194- pub ( crate ) struct Cli {
155+ pub struct Cli {
195156 /// The command to run.
196157 #[ clap( subcommand) ]
197- command : Command ,
158+ pub command : Command ,
198159}
199160
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 > {
201163 let dir = directories:: BaseDirs :: new ( )
202164 . with_context ( || "could not find the user home directory" ) ?
203165 . cache_dir ( )
0 commit comments