-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Renamed ping to info in store #8975
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, left a couple of comments, but looks good overall. Great to see someone help tacking this :)
src/nix/main.cc
Outdated
@@ -126,7 +126,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs | |||
{"ls-store", {"store", "ls"}}, | |||
{"make-content-addressable", {"store", "make-content-addressed"}}, | |||
{"optimise-store", {"store", "optimise"}}, | |||
{"ping-store", {"store", "ping"}}, | |||
{"info-store", {"store", "info"}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That one shouldn't be changed. The ping-store
alias should stay the same.
We should also have a backwards-compat alias from store ping
to store info
I think. @Ericson2314 @edolstra is there a mechanism for aliasing subcommands? If not we can always do it manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. So, According to the comment, the ping-store need to stay the same but, the vector alias of it {"store", "info"}
can be as it is. please let me know if this is the expectation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not off-hand know of a mechanism for aliasing within subcommands, but if we look how this is implemented with overriding rewriteArgs
, perhaps that can be done within the Store
command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the store command in store-info.cc
. After that, I had a suggestion that, if we are renaming the command from ping
to info
, then I thought it would be better to also update the alias accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what you are saying? I am saying you can modify src/nix/store.cc
to that nix store ping
is an alias for nix store info
in addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know if there are any documentations available for this aliasing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no documentation for this exact task. You would need to figure out what main.cc
is doing and recreate it in store.cc
. I am sorry.
It would be good to add API docs to rewriteArgs
where it is declared (args.hh
). Perhaps once you've figured out what is going on your can do that, so the next person is less stuck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will try to implement it in store.cc. Thanks.
src/nix/info-store.cc
Outdated
return | ||
#include "ping-store.md" | ||
; | ||
return #include "info-store.md" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal (and no blocker to me), but since we're renaming things, we could rename this to store-info.md
to match the command (ping-store
comes from the original command name and was already out of sync)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
store-info files are renamed according to the command name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @thufschmitt is saying is that it would be good to call both files store-info.{cc,md}
. The file was never properly renamed when the commands were made hierarchical before, but we should fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will try to implement the aliasing in store.cc. Thanks
@@ -41,9 +41,9 @@ struct CmdPingStore : StoreCommand, MixJSON | |||
if (auto version = store->getVersion()) | |||
res["version"] = *version; | |||
if (auto trusted = store->isTrustedClient()) | |||
res["trusted"] = *trusted; | |||
res["trusted"] = *trusted ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should eventually not need this via the enum struct
change I proposed for TrustedFlag
, but it is fine to do this for now and that in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. I saw that TrustedFag is storing only bool value. But, somehow the value is printing 1/0 instead of true or false. So, I added this condition here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because it is the wrong type of enum. The other type of enum will remove the implicit coercions that are causing the problem here.
@Ericson2314 I tried to add the aliasing in Kindly please review the commit: fc094c1 and let me know if it is ok. |
src/nix/store-info.cc
Outdated
} else { | ||
nlohmann::json res; | ||
Finally printRes([&]() { | ||
logger->cout("%s", res); | ||
logger->cout("%s", res.dump(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this change? formatting the JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not usually format output json, so I for consistency I don't think we want to here either. If we decide to do so, it should be across the board not a one-off decision for one command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I will revert the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ericson2314 the changes related to aliasing which was done in args.cc
and store info json formatting were reverted. i will try the new approach you mentioned for aliasing in main.cc
.
@vicky1999 See |
Motivation
I have renamed the command
store ping
tostore info
Context
This change is required in #8914
Changes made:
Screenshot
Priorities
Add 👍 to pull requests you find important.