History

Use --file-name flag to shorten displayed path (#198)

Sebastian Thiel committed 5 years ago

Commit 6e6dcda1 parent 4cc02133 files · +11 −4Browse files

Unified · Split

3 files
  1. cargo-smart-release/src/bat.rs +3 −2
  2. cargo-smart-release/src/command/changelog.rs +4 −1
  3. cargo-smart-release/src/command/release/manifest.rs +4 −1
cargo-smart-release/src/bat.rs+3−2
@@ -19,7 +19,7 @@ impl Support { · 18 unmodified lines
1919 }
2020 }
2121
22− pub fn display_to_tty(&self, path: &Path) -> io::Result<()> {
22+ pub fn display_to_tty(&self, path: &Path, path_for_title: &Path) -> io::Result<()> {
2323 if !self.bat.found {
2424 log::info!(
2525 "Would want to use 'bat' for colored preview of '{}', but it wasn't available in the PATH.",
@@ -28,7 +28,8 @@ impl Support { · 2 unmodified lines
2828 return Ok(());
2929 }
3030 if Command::new("bat")
31− .args(&["--paging=always", "-l=md"])
31+ .args(&["--paging=always", "-l=md", "--file-name"])
32+ .arg(path_for_title)
3233 .arg(path)
3334 .status()?
3435 .success()
cargo-smart-release/src/command/changelog.rs+4−1
@@ -50,7 +50,10 @@ pub fn changelog(opts: Options, crates: Vec<String>) -> anyhow::Result<()> { · 49 unmodified lines
5050 file.write_all(buf.as_bytes())
5151 })?;
5252 if let Some(bat) = bat.as_ref() {
53− bat.display_to_tty(lock.lock_path())?;
53+ bat.display_to_tty(
54+ lock.lock_path(),
55+ lock.resource_path().strip_prefix(&ctx.root.to_path_buf())?,
56+ )?;
5457 }
5558 if !opts.dry_run {
5659 pending_changes.push(lock);
cargo-smart-release/src/command/release/manifest.rs+4−1
@@ -239,7 +239,10 @@ pub(in crate::command::release_impl) fn edit_version_and_fixup_dependent_crates_ · 238 unmodified lines
239239 .iter()
240240 .filter(|(_, has_changes, _)| *has_changes)
241241 {
242− bat.display_to_tty(lock.lock_path())?;
242+ bat.display_to_tty(
243+ lock.lock_path(),
244+ lock.resource_path().strip_prefix(&ctx.base.root.to_path_buf())?,
245+ )?;
243246 }
244247 }
245248

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t