Skip to content

Commit 5631fd6

Browse files
committed
specify path git -g
1 parent b2ac88f commit 5631fd6

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
* [ ] [Feature] File watcher for zipped epw (and epw??) files
99
* [ ] [Feature] Auto unzip folder and copy lib to libs folder
1010
* [ ] [Code] New struct for CLI-only options
11-
* [ ] [Feature] When using `-g`, treat input as output path
11+
* [x] [Feature] When using `-g`, treat input as output path

cli.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ args:
5252
takes_value: false
5353
multiple: false
5454
conflicts_with:
55-
- input
5655
- id
5756
- config
5857
- watch

src/config.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,25 @@ impl Config {
184184

185185
}
186186

187-
pub fn generate() -> LLResult<()> {
187+
pub fn generate(input: &String) -> LLResult<String> {
188188

189-
let path = PathBuf::from(LL_CONFIG);
189+
// let path = PathBuf::from(LL_CONFIG);
190+
let path = PathBuf::from(match input.trim().is_empty() {
191+
true => LL_CONFIG,
192+
false => input
193+
});
190194

191-
if path.exists() {
195+
if path.clone().exists() {
192196

193-
return Err(LLError::new(format!("{} already exists", LL_CONFIG)))
197+
return Err(LLError::new(format!("{} already exists", path.to_str().unwrap())))
194198

195199
}
196200

197-
match fs::write(path, include_str!("../LibraryLoader.example.toml")) {
198-
Ok(v) => Ok(v),
201+
match fs::write(&path, include_str!("../LibraryLoader.example.toml")) {
202+
Ok(_) => {
203+
let path_as_string = String::from(path.to_str().unwrap());
204+
Ok(path_as_string)
205+
},
199206
Err(e) => Err(LLError::new(format!("{}", e)))
200207
}
201208

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ fn real_main() -> LLResult<()> {
3434

3535
if conf.generate_config {
3636

37-
return match Config::generate() {
37+
return match Config::generate(&conf.input) {
3838
Ok(v) => {
39-
println!("Generated {}", consts::LL_CONFIG);
40-
Ok(v)
39+
println!("Generated {}", v);
40+
Ok(())
4141
},
4242
Err(e) => Err(e)
4343
}

0 commit comments

Comments
 (0)