diff --git a/README.md b/README.md
index 59fc347..b32b9b6 100644
--- a/README.md
+++ b/README.md
@@ -14,17 +14,15 @@ Are you _**also**_ frustrated from moving your hands away from the keyboard to v
`git-view` alleviates that pain by allowing you to chuck away your mouse!
-> (n)vim users rejoice :P
-
-**_Important Note: You should always use `git view -h` instead of `git view --help` as the manpage/html files are NOT included._**
+> **Note:**
+> You should always use `git view -h` instead of `git view --help` as the manpage/html files are **NOT** included.
## Features
- [x] View Branches, Commits & Issues
- [x] Custom Suffix
- [x] Custom Remote
-- [ ] View Profile
-- [ ] View Current Directory
+- [x] View Current Directory
## Installation
diff --git a/src/bin/git-view.rs b/src/bin/git-view.rs
index 07c6942..295980b 100644
--- a/src/bin/git-view.rs
+++ b/src/bin/git-view.rs
@@ -35,6 +35,16 @@ fn main() {
.takes_value(true)
.display_order(2),
)
+ .arg(
+ Arg::new("issue")
+ .long_help("The issue number to view on the git repository\n[default: open issue from current branch]")
+ .short('i')
+ .long("issue")
+ .default_missing_value("branch")
+ .conflicts_with("commit")
+ .takes_value(true)
+ .display_order(3),
+ )
.arg(
Arg::new("commit")
.long_help("The commit to view git repository on\n[default: current commit]")
@@ -43,33 +53,33 @@ fn main() {
.value_name("hash")
.default_missing_value("current")
.conflicts_with_all(&["remote", "branch"])
- .display_order(3),
+ .display_order(4),
+ )
+ .arg(
+ Arg::new("path")
+ .long_help("The directory/file to view on the git repository\n[default: current working directory]")
+ .short('p')
+ .long("path")
+ .default_missing_value("current-working-directory")
+ .conflicts_with("issue")
+ .takes_value(true)
+ .value_hint(clap::ValueHint::AnyPath)
+ .display_order(5),
)
.arg(
Arg::new("suffix")
- .long_help("A suffix to append onto the git repository URL")
+ .long_help("A suffix to append onto the base git repository URL")
.short('s')
.long("suffix")
.value_name("suffix")
.takes_value(true)
- .display_order(4),
- )
- .arg(
- Arg::new("issue")
- .long_help("The issue number to view\n[default: open issue from remote branch]")
- .short('i')
- .long("issue")
- .default_missing_value("branch")
- .conflicts_with("commit")
- .takes_value(true)
- .display_order(5),
+ .display_order(6),
)
.arg(
Arg::new("print")
.long_help("Don't open browser and print the URL")
- .short('p')
.long("print")
- .display_order(6),
+ .display_order(7),
);
let matches = matches.get_matches();
@@ -79,6 +89,7 @@ fn main() {
matches.value_of("commit"),
matches.value_of("suffix"),
matches.value_of("issue"),
+ matches.value_of("path"),
matches.is_present("print"),
);
diff --git a/src/git.rs b/src/git.rs
index 83d4e7d..4a700f1 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -33,6 +33,7 @@ pub(crate) enum GitCommand<'a> {
IsValidRemote(&'a str),
CurrentTag,
CurrentCommit,
+ CurrentWorkingDirectory,
}
pub enum GitOutput {
@@ -51,6 +52,7 @@ pub trait GitTrait {
fn is_valid_remote(&self, remote: &str) -> Result;
fn get_current_tag(&self) -> Result;
fn get_current_commit(&self) -> Result;
+ fn get_current_working_directory(&self) -> Result;
}
impl GitTrait for Git {
@@ -89,6 +91,10 @@ impl GitTrait for Git {
fn get_current_commit(&self) -> Result {
execute(command(GitCommand::CurrentCommit)?)
}
+
+ fn get_current_working_directory(&self) -> Result {
+ execute(command(GitCommand::CurrentWorkingDirectory)?)
+ }
}
fn command(git_command: GitCommand) -> Result