@@ -10,7 +10,13 @@ use serde::Deserialize;
10
10
fn main ( ) -> Result < ( ) > {
11
11
let args = Args :: parse ( ) ;
12
12
13
- let bundled_code = bundle_crate ( & args. crate_name , Path :: new ( & args. workspace ) )
13
+ let workspace_path = if args. remote {
14
+ download_remote_repository ( ) ?
15
+ } else {
16
+ args. workspace . into ( )
17
+ } ;
18
+
19
+ let bundled_code = bundle_crate ( & args. crate_name , & workspace_path)
14
20
. with_context ( || format ! ( "Failed to bundle crate '{}'" , args. crate_name) ) ?;
15
21
16
22
if args. skip_compile {
@@ -58,14 +64,51 @@ struct Args {
58
64
crate_name : String ,
59
65
60
66
/// Path to the workspace root
61
- #[ clap( short, long, default_value = "." ) ]
67
+ #[ clap( short, long, default_value = "." , conflicts_with = "remote" ) ]
62
68
workspace : String ,
63
69
70
+ /// Use remote repository (https://github.com/ia7ck/rust-competitive-programming)
71
+ #[ clap( long, conflicts_with = "workspace" ) ]
72
+ remote : bool ,
73
+
64
74
/// Skip compilation check
65
75
#[ clap( long) ]
66
76
skip_compile : bool ,
67
77
}
68
78
79
+ fn download_remote_repository ( ) -> Result < std:: path:: PathBuf > {
80
+ eprintln ! ( "📥 Cloning remote repository..." ) ;
81
+
82
+ let temp_dir = std:: env:: temp_dir ( ) . join ( format ! (
83
+ "rust-competitive-programming-{}" ,
84
+ std:: process:: id( )
85
+ ) ) ;
86
+
87
+ if temp_dir. exists ( ) {
88
+ fs:: remove_dir_all ( & temp_dir) . context ( "Failed to remove existing temp directory" ) ?;
89
+ }
90
+
91
+ let output = Command :: new ( "git" )
92
+ . args ( [
93
+ "clone" ,
94
+ "--depth" ,
95
+ "1" ,
96
+ "https://github.com/ia7ck/rust-competitive-programming.git" ,
97
+ ] )
98
+ . arg ( & temp_dir)
99
+ . output ( )
100
+ . context ( "Failed to run git clone. Make sure git is installed and available in PATH." ) ?;
101
+
102
+ if !output. status . success ( ) {
103
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
104
+ anyhow:: bail!( "Git clone failed:\n {}" , stderr) ;
105
+ }
106
+
107
+ eprintln ! ( "✅ Repository cloned to temporary directory" ) ;
108
+
109
+ Ok ( temp_dir)
110
+ }
111
+
69
112
struct CrateInfo {
70
113
content : String ,
71
114
dependencies : Vec < String > ,
0 commit comments