Skip to content

Commit

Permalink
0.4.0
Browse files Browse the repository at this point in the history
adds the an option to specify selected_dir instead of using a selector
  • Loading branch information
zdcthomas committed May 13, 2020
1 parent a2e21b6 commit dbf3eef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dmux"
version = "0.3.1"
version = "0.4.0"
authors = ["Zachary Thomas <[email protected]>"]
edition = "2018"

Expand Down
23 changes: 18 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ fn args<'a>() -> clap::ArgMatches<'a> {
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.arg(
Arg::with_name("selected_dir")
.help("Instead of opening the selector to pick a dir, open it is the desired dir.")
.takes_value(true),
)
.arg(
Arg::with_name("session_name")
.short("s")
Expand Down Expand Up @@ -218,11 +223,7 @@ fn main() {
};

match args.subcommand_name() {
None => {
if let Some(selected_dir) = Selector::new(&config.search_dir).select_dir() {
setup_workspace(selected_dir, config)
}
}
None => open_in_selected_dir(args, config),

Some("clone") => {
let clone_args = args.subcommand_matches("clone").unwrap();
Expand All @@ -244,6 +245,18 @@ fn main() {
}
}

fn open_in_selected_dir(args: clap::ArgMatches, config: Config) {
if let Ok(selected_dir) = value_t!(args.value_of("selected_dir"), PathBuf) {
if selected_dir.exists() {
setup_workspace(selected_dir, config)
} else {
panic!("dude, that's not a path")
}
} else if let Some(selected_dir) = Selector::new(&config.search_dir).select_dir() {
setup_workspace(selected_dir, config)
}
}

// -> Result<Output, Error>
fn git_url_to_dir_name(url: &Url) -> String {
let segments = url.path_segments().ok_or_else(|| "cannot be base").unwrap();
Expand Down

0 comments on commit dbf3eef

Please sign in to comment.