This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganize settings to allow them to be overwritten by CLI arguments
- Loading branch information
1 parent
8c6805d
commit b0625f6
Showing
9 changed files
with
108 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use structopt::StructOpt; | ||
|
||
use crate::{ | ||
dirs::{get_dirs, GetDirsError}, | ||
finder::find, | ||
settings::Settings, | ||
}; | ||
|
||
#[derive(StructOpt)] | ||
pub struct Cmd { | ||
#[structopt(long)] | ||
pub search_dirs: Option<Vec<String>>, | ||
#[structopt(long)] | ||
pub preview_files: Option<Vec<String>>, | ||
#[structopt(long)] | ||
pub preview: Option<bool>, | ||
#[structopt(long)] | ||
pub preview_with_bat: Option<bool>, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self) -> Result<Option<String>, GetDirsError> { | ||
Settings::merge_find_args(self); | ||
let dirs = get_dirs()?; | ||
let selected = find(&dirs); | ||
Ok(selected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
pub mod ctrlgcommand; | ||
use std::error::Error; | ||
use structopt::StructOpt; | ||
|
||
pub mod find; | ||
pub mod init; | ||
|
||
#[derive(StructOpt)] | ||
pub enum CtrlgCommand { | ||
#[structopt(about = "Find a directory based on configured globbing patterns")] | ||
Find(find::Cmd), | ||
#[structopt(about = "Set up ctrl+g keybind for specified shell")] | ||
Init(init::Cmd), | ||
} | ||
|
||
impl CtrlgCommand { | ||
pub fn run(self) -> Result<(), Box<dyn Error>> { | ||
match self { | ||
CtrlgCommand::Find(cmd) => { | ||
let selected = cmd.run()?; | ||
if let Some(selected) = selected { | ||
println!("{}", selected); | ||
} | ||
Ok(()) | ||
} | ||
CtrlgCommand::Init(cmd) => { | ||
let script = cmd.run(); | ||
println!("{}", script); | ||
Ok(()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters