-
Notifications
You must be signed in to change notification settings - Fork 507
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
1 parent
347c19d
commit 23be67d
Showing
24 changed files
with
90 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
extern crate navi; | ||
|
||
use std::fmt::Debug; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[error( | ||
"\rHey, listen! navi encountered a problem. | ||
Do you think this is a bug? File an issue at https://github.com/denisidoro/navi." | ||
)] | ||
pub struct FileAnIssue { | ||
#[source] | ||
source: anyhow::Error, | ||
} | ||
|
||
impl FileAnIssue { | ||
pub fn new<SourceError>(source: SourceError) -> Self | ||
where | ||
SourceError: Into<anyhow::Error>, | ||
{ | ||
FileAnIssue { | ||
source: source.into(), | ||
} | ||
} | ||
} | ||
|
||
fn main() -> Result<(), anyhow::Error> { | ||
navi::handle_config(navi::config_from_env()).map_err(|e| navi::FileAnIssue::new(e).into()) | ||
navi::handle_config(navi::config_from_env()).map_err(|e| FileAnIssue::new(e).into()) | ||
} |
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,42 @@ | ||
use crate::shell::BashSpawnError; | ||
use anyhow::Error; | ||
use std::process::Command; | ||
|
||
pub fn copy(text: String) -> Result<(), Error> { | ||
let cmd = r#" | ||
exst() { | ||
type "$1" &>/dev/null | ||
} | ||
_copy() { | ||
if exst pbcopy; then | ||
pbcopy | ||
elif exst xclip; then | ||
xclip -selection clipboard | ||
elif exst clip.exe; then | ||
clip.exe | ||
else | ||
exit 55 | ||
fi | ||
}"#; | ||
|
||
Command::new("bash") | ||
.arg("-c") | ||
.arg( | ||
format!( | ||
r#"{} | ||
read -r -d '' x <<'NAVIEOF' | ||
{} | ||
NAVIEOF | ||
echo -n "$x" | _copy"#, | ||
cmd, text | ||
) | ||
.as_str(), | ||
) | ||
.spawn() | ||
.map_err(|e| BashSpawnError::new(cmd, e))? | ||
.wait()?; | ||
|
||
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
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 was deleted.
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
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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