-
Notifications
You must be signed in to change notification settings - Fork 310
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
ostree: Describe subcommands in help output #1267
ostree: Describe subcommands in help output #1267
Conversation
Looks like... the failure was because... the test-help.sh file also reads description as one of the potential commands :(.
:'(. |
Ahh, heh. I think you might need to tweak the |
} OstreeAdminInstUtilCommand; | ||
|
||
static OstreeAdminInstUtilCommand admin_instutil_subcommands[] = { | ||
#ifdef HAVE_SELINUX | ||
{ "selinux-ensure-labeled", ot_admin_instutil_builtin_selinux_ensure_labeled }, | ||
{ "selinux-ensure-labeled", ot_admin_instutil_builtin_selinux_ensure_labeled, | ||
"relabel all or part of a deployment" }, |
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.
Let's capitalize these too to be consistent.
{ "grub2-generate", ot_admin_instutil_builtin_grub2_generate }, | ||
{ NULL, NULL } | ||
{ "set-kargs", ot_admin_instutil_builtin_set_kargs, | ||
"set new kernel command line arguments(Not stable) " }, |
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.
Minor: trailing space there!
@@ -41,7 +41,7 @@ gboolean | |||
ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error) | |||
{ | |||
g_autoptr(OstreeRepo) repo = NULL; | |||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME- Remote one cookie from remote"); | |||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME- Remove one cookie from remote"); |
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 looks good overall! The only issue I have is that the description string is now duplicated twice right? Once in the struct and once in the parameter string?
Maybe let's pass the struct to the command so that ostree_option_context_parse
can set it as the summary? Similar to what we do in rpm-ostree.
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.
yea, we could do like coreos/rpm-ostree@12c34bb.
But it kinda becomes tricky when we have multiple type of commands included in Ostree. One for OstreeAdmin
, OstreeAdminInstutil
, OstreeRemote
, and things become a bit messier when we have two different parsing method. ostree_option_context_parse
and ostree_admin_option_context_parse
. So, going through a similar invocation
line as rpm-ostree may involve many changes/refactoring to the existing code.
But, it may be not that difficult if we can merge/change all type of different commands in ostree into one whole OstreeCommand
, and then passing the struct along won't be that hard. But that also involves changing a lot of code :(, since I am a newbie here, I am inexperienced about whether or not it is worth to do so :p. But I think for now will just go ahead and have it a try :)
src/ostree/ot-builtin-static-delta.c
Outdated
{ "apply-offline", ot_static_delta_builtin_apply_offline }, | ||
{ NULL, NULL } | ||
{ "list", ot_static_delta_builtin_list, | ||
"list static delta files" }, |
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.
s/list/List/
Added a description argument to all type of commands. Now when we include -h or --help for commands that contain subcommands, the description for those subcommands are shown. The added subcommands help will be provided to the following commands: - ostree -h - ostree admin -h - ostree admin instutil -h - ostree remote -h - ostree static-delta -h
This is a similar approach as coreos/rpm-ostree@12c34bb. One thing to note is when we parse the admin related functions, we still keep the old admin related flags, and added a new parameter to represent the command struct. This allows us to identify the caller of the function, making it easier for us to possibly deduplicate the subcommand handling in the future. A similar approach is done in rpm-ostree: coreos/rpm-ostree@83aeb01 This also makes it easier for us to change the prototype of the function. If we want to add something new in the future, we won't need to touch every prototype.
a25ada4
to
808a446
Compare
So Rebased... and addressed most of comments ⬆️.
This patch will be the prep for that. Another patch will hopefully come soon :). There are actually a lot of files being changed in order to be able to "pass the command struct" through builtins. Also, it is my first time doing this type of refactoring, so I might make mistakes and please tell me if I did it wrong. :) So, for the most recent patch, there are a few things worth mentioning(I think): 1: The built in flags for admin related commands are 'OSTREE_BUILTIN_FLAG_NO_REPO', and the OstreeAdminBuiltinFlags is unchanged and remained the same. The 2: The default builtin flag in 3: The other changes are all very similar to that from rpm-ostree coreos/rpm-ostree@12c34bb |
This is similar idea as coreos/rpm-ostree@5c0bf88, The duplicated description is now removed, and the description of the command is now displayed beneath the Usage. For example: ostree cat -h will output the following: "Usage: ostree cat [OPTION?] COMMIT PATH... Concatenate contents of files"
src/ostree/ot-main.c
Outdated
g_autoptr(GString) description_string = g_string_new (invocation->command->description); | ||
|
||
g_string_append (description_string, "\n\n"); | ||
g_string_prepend (new_summary_string, description_string->str); |
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.
Could avoid another GString
allocation here with:
g_string_prepend (new_summary_string, "\n\n");
g_string_prepend (new_summary_string, invocation->command->description);
But eh. If you prefer as is that's OK by me too.
src/ostree/main.c
Outdated
*/ | ||
{ "admin", OSTREE_BUILTIN_FLAG_NO_REPO, | ||
ostree_builtin_admin, | ||
"Commands that needs admin privilege" }, |
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'd say Commands for managing a host system booted with ostree
or so.
src/ostree/main.c
Outdated
"Commands that needs admin privilege" }, | ||
{ "cat", OSTREE_BUILTIN_FLAG_NONE, | ||
ostree_builtin_cat, | ||
"Concatenate contents of files"}, |
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.
Maybe Like Unix cat, but reads data from an OSTree repository
?
Hum...perhaps we shouldn't be rewriting the descriptions in this commit. Nevermind, let's do that after.
Is this still WIP? Looks pretty good to me. |
Not any more :), I just updated the title, but unable to remove the label. And thanks for review, will address the comments shortly :). |
Sure :), added fixup based on comments above ⬆️ |
Nice work, thanks a lot! |
This is a similar approach as coreos/rpm-ostree@12c34bb. One thing to note is when we parse the admin related functions, we still keep the old admin related flags, and added a new parameter to represent the command struct. This allows us to identify the caller of the function, making it easier for us to possibly deduplicate the subcommand handling in the future. A similar approach is done in rpm-ostree: coreos/rpm-ostree@83aeb01 This also makes it easier for us to change the prototype of the function. If we want to add something new in the future, we won't need to touch every prototype. Closes: #1267 Approved by: cgwalters
This is similar idea as coreos/rpm-ostree@5c0bf88, The duplicated description is now removed, and the description of the command is now displayed beneath the Usage. For example: ostree cat -h will output the following: "Usage: ostree cat [OPTION?] COMMIT PATH... Concatenate contents of files" Closes: #1267 Approved by: cgwalters
☀️ Test successful - status-atomicjenkins |
Thanks for the review :) |
The added subcommands help will be provided to the following commands:
This is very similar to coreos/rpm-ostree#916
Closes: #1163
Demo: