Skip to content

removed jq dependency #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2021
Merged

Conversation

ceremcem
Copy link

No description provided.

@sysnux
Copy link
Owner

sysnux commented Jan 13, 2021

ceremcem, I appreciate your work, but I'm not sure on this PR.
jq is not a requirement for btrfs-snapshots-diff, just to get a nicer output on the tests. And I don't like adding yet another argument to btrfs-snapshots-diff, I think there are already too many.

@ceremcem
Copy link
Author

That's of course your call, no problem.

Please consider that the tests are the mandatory part of "tutorial" for this tool. It was the first thing I took a look at least. As the "default" way of displaying JSON is "Pretty printing", I guess jq can be considered pretty much a requirement. Raw JSON output is useful when there are file size considerations.

In this context, both raw JSON output and jq is a requirement, which makes the --pretty switch mandatory as well.

Regarding to "avoiding one more switch to keep things clean": Consider how many lines we saved from both documentation and the code, by adding one --pretty line into the documentation and a few lines into the code.

Again, it's up to you.

@ceremcem
Copy link
Author

ceremcem commented Jan 14, 2021

I just wonder, if the problem is adding yet another argument, then simply removing this argument from the documentation both

  • Satisfies your requirement
  • Removes an external dependency

Would that work for you?

@sysnux
Copy link
Owner

sysnux commented Jan 14, 2021

Well, for me the JSON output is useful for other programs (or written to file), not to be displayed, exactly like done in the tests with jq. Same as CSV output.
The point is not to make JSON output nice for human; for this by_path should be used.

@ceremcem
Copy link
Author

This doesn't answer my question :) Will undocumenting the --pretty switch satisfy your expectation?

@sysnux
Copy link
Owner

sysnux commented Jan 14, 2021

Sorry, what do you mean by undocumenting --pretty? JSON pretty output would be default?

@ceremcem
Copy link
Author

Let me show you:

diff --git a/README.md b/README.md
index 725dbd8..112129f 100644
--- a/README.md
+++ b/README.md
@@ -26,12 +26,11 @@ Usage
          -a, --by_path         Group commands by path
          -s, --csv             CSV output
          -j, --json            JSON output (commands only)
-         --pretty              Pretty print the JSON output (Requires --json option)
          -b, --bogus           Add bogus renamed_from action (used only when grouping by path)
 
 
 * `--json` (`-j`), available for commands only, will output a list of 
-commands in JSON format. `--pretty` switch requires this option. 
+commands in JSON format.
 
 * `--csv` (`-s`) will produce on line for each modification, instead of 
 formatted output: the first column is the path, then each action taken on the 
diff --git a/btrfs-snapshots-diff.py b/btrfs-snapshots-diff.py
index 5682d07..8cd1ce4 100755
--- a/btrfs-snapshots-diff.py
+++ b/btrfs-snapshots-diff.py
@@ -569,7 +569,7 @@ def main():
         '-j', '--json', action='store_true', help='JSON output (commands only)'
     )
     parser.add_argument(
-        '--pretty', action='store_true', help='Pretty print the JSON output'
+        '--pretty', action='store_true', help=argparse.SUPPRESS
     )
     parser.add_argument(
         '-b',

No one will even know there is a --pretty switch.

@sysnux
Copy link
Owner

sysnux commented Jan 14, 2021

ok, let's do it this way!
Another nit: you changed btrfs to upper case in README (...and BTRFS obviously...): that is wrong, as the requirement is on the btrfs command.
Could you please send an updated PR?

@ceremcem
Copy link
Author

Another nit: you changed btrfs to upper case in README

Of course. The idea was it would be either "btrfs" or "BTRFS" (or maybe "Btrfs", as stated here: https://en.wikipedia.org/wiki/Btrfs). I offer to change it to btrfs or Btrfs. Which one would you prefer?

@sysnux
Copy link
Owner

sysnux commented Jan 14, 2021

I propose:

and the btrfs command obviously.

@ceremcem
Copy link
Author

Okay.

@ceremcem
Copy link
Author

Ready.

@ceremcem ceremcem force-pushed the remove-jq-dependency branch from f2e9aba to bc33f61 Compare January 14, 2021 19:51
@sysnux sysnux merged commit 5916f99 into sysnux:master Jan 14, 2021
@sysnux
Copy link
Owner

sysnux commented Jan 14, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants