aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2020-11-16 15:26:19 +0100
committerBond_009 <bond.009@outlook.com>2020-11-16 15:26:19 +0100
commit256f1f305fc47b06d470abf66dc3dfdcd1d6b790 (patch)
tree43f167c5795873ab933af9d932102de076cbcd5b /src/main.rs
parent5f2f7e824f0af2550f2a3d52dfbbe5ea7fba6499 (diff)
Use upstream repo name when no name is specified
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 2007e39..18912d6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
mod config;
+mod utils;
use std::{
env,
@@ -65,7 +66,12 @@ fn init() {
path.push(Path::new(
project.path.as_ref().unwrap_or(&config.default_path),
));
- path.push(project.name);
+
+ match project.name {
+ Some(name) => path.push(name),
+ None => path.push(utils::get_repo_name(&project.url))
+ };
+
if path.exists() {
println!("{:#?} already exists, skipping.", path);
continue;
@@ -94,7 +100,12 @@ fn update() {
path.push(Path::new(
project.path.as_ref().unwrap_or(&config.default_path),
));
- path.push(project.name);
+
+ match project.name {
+ Some(name) => path.push(name),
+ None => path.push(utils::get_repo_name(&project.url))
+ };
+
if !path.exists() {
println!("{:#?} doesn't exist, skipping.", &path);
continue;