Comments (12)
How about this? This is what I use.
riff < hello.diff
from riff.
How about this? This is what I use.
riff < hello.diff
Way less "natural" than even piping from cat
, at least for me. It's a "pattern" I encounter/use very rarely, contrary to cat <file> | cmd
, cmd <file>
, and cmd -f <file>
from riff.
I think having an option for this would be fine.
Maybe --file
or -f
as you hinted at.
I'd slightly prefer having the --file
form only, to lower the risk of colliding with any plain diff
options. But neither macOS diff
nor GNU diff
has any short -f
option so I guess just -f
should be fine as well.
Wanna make a PR?
from riff.
Wanna make a PR?
sure I'll have a look
from riff.
So I finally had the time to have a look, but with the way the custom argument parser is done it's going to be painful to add a flag that takes an option.
from riff.
In this dive in the code, I found a funny bug
consume()
is so over-eager that it deletes the second file from argv.
Additionally, it would normally be possible to end option/flag parsing with --
like in the touch
calls, but riff does not support that
I would recommend switching to an argument parsing crate like clap
, both to ease extensibility, to avoid argument parsing edge-cases like these, to provide proper CLI validation, and to follow argument parsing conventions and best practices like --
. The structure of the rest of the code would make that an easy switch. I also offer to make a PR for that.
from riff.
I started looking into that here:
https://github.com/walles/riff/commits/johan/clap
It mostly works, but Clap supports only one Usage
description which I find unfortunate. Not sure what to do with that...
from riff.
It mostly works, but Clap supports only one
Usage
description which I find unfortunate. Not sure what to do with that...
Ah yeah clap's default is not the best. You can override the usage line(s) with override_usage
and it supports multiple lines
To use it with the derive, you just add override_usage = USAGE
here
Line 59 in d1c5c71
from riff.
Successfully added it back
diff --git a/src/main.rs b/src/main.rs
index 97c818e..6964892 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,10 @@ mod refiner;
mod token_collector;
mod tokenizer;
+const USAGE: &str = "diff ... | riff\n \
+ riff [-b] [--no-pager] <file1> <file2>\n \
+ riff [-b] [--no-pager] <directory1> <directory2>";
+
const HELP_TEXT_FOOTER: &str = r#"Installing riff in the $PATH:
sudo cp riff /usr/local/bin
@@ -56,7 +60,7 @@ const PAGER_FORKBOMB_STOP: &str = "_RIFF_IGNORE_PAGER";
const GIT_VERSION: &str = git_version!(cargo_prefix = "");
#[derive(Parser)]
-#[command(version = GIT_VERSION, name = "riff", about = "Colors diff output, highlighting the changed parts of every line.", after_help = HELP_TEXT_FOOTER)]
+#[command(version = GIT_VERSION, name = "riff", about = "Colors diff output, highlighting the changed parts of every line.", after_help = HELP_TEXT_FOOTER, override_usage = USAGE)]
struct Options {
/// First file to compare
#[arg(requires("file2"))]
file1
and file2
could be Option<PathBuf>
to automatically get a valid path, and the check for the paths being file-file or dir-dir could be done earlier since the paths would already be paths from the get-go.
from riff.
Branch merged, thanks for the help!
If you see something that can be adjusted do let me know.
Now it should be rather straight forward to add that new option!
from riff.
If you see something that can be adjusted do let me know.
The lack of the seven spaces on the usage lines gives an odd rendering to the usage lines, since they normally start on the same line as Usage:
in most cli tools, but that's just styling.
from riff.
The lack of the seven spaces on the usage lines gives an odd rendering to the usage lines, since they normally start on the same line as
Usage:
in most cli tools, but that's just styling.
Arguments and Options are indented by two, so I'll stick to that for Usage as well.
As you say, this is a matter of taste...
from riff.
Related Issues (20)
- - lines not highlighted if next to a line entirely of -----
- "No newline at end of file" feature is dependent on system language being english HOT 3
- Remove-ending-newline highlighing with added lines
- Highlight renames
- Special highlighting for adds-only HOT 1
- Ignore newline vs space HOT 1
- Bogus non-leading-tab warnings HOT 1
- Readability issues in recently added features, +config file? HOT 16
- Panic while running `git diff` HOT 3
- -b flag forces presence of <C1> <C2>
- Merge conflict highlight HOT 13
- combined git diff highlighting
- Misaligned timestamps HOT 2
- Output is colored even when redirecting it into a pipe HOT 9
- Diff filter (patch) colors broken in 2.32 HOT 3
- [feature request] side-by-side mode HOT 3
- setting riff for log pager removes log colours HOT 1
- crash on git diff HOT 12
- Improve conflict highlighting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riff.