-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::path::PartialPath; | ||
use crate::root::Root; | ||
use anyhow::{anyhow, Result}; | ||
use clap::Parser; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct Cmd { | ||
/// Remote host of the repository. | ||
/// Defaults to github.com. | ||
#[clap(long)] | ||
host: Option<String>, | ||
/// Owner name of the repository. | ||
owner: Option<String>, | ||
/// Repository name. | ||
repo: Option<String>, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(self) -> Result<()> { | ||
let root = Root::find()?; | ||
let path = PartialPath { | ||
root: &root, | ||
host: self.host, | ||
owner: self.owner, | ||
repo: self.repo, | ||
}; | ||
|
||
let path = PathBuf::from(path); | ||
if !path.exists() || !path.is_dir() { | ||
return Err(anyhow!( | ||
"The path does not exist or is not a directory. Did you cloned the repository?" | ||
)); | ||
} | ||
|
||
println!("{}", path.to_string_lossy()); | ||
|
||
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