X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Fcmds.c;h=f0c0458e3a1720745430013218b35ce3fe20c2ee;hb=71fa671c6dd4decccb3d99941a5d02b0d13e0152;hp=5c7d553086683a3d087014e2eee10d7c6e75cec2;hpb=e7eca50046e9a69dac27c0bee832af0a3014e02c;p=libguestfs.git diff --git a/fish/cmds.c b/fish/cmds.c index 5c7d553..f0c0458 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -40,6 +40,7 @@ void list_commands (void) printf ("%-20s %s\n", "aug-init", "create a new Augeas handle"); printf ("%-20s %s\n", "aug-insert", "insert a sibling Augeas node"); printf ("%-20s %s\n", "aug-load", "load files into the tree"); + printf ("%-20s %s\n", "aug-ls", "list Augeas nodes under a path"); printf ("%-20s %s\n", "aug-match", "return Augeas nodes which match path"); printf ("%-20s %s\n", "aug-mv", "move Augeas node"); printf ("%-20s %s\n", "aug-rm", "remove an Augeas path"); @@ -153,7 +154,7 @@ void display_command (const char *cmd) pod2text ("read-lines - read file as lines", " read-lines \n\nReturn the contents of the file named C.\n\nThe file contents are returned as a list of lines. Trailing\nC and C character sequences are I returned.\n\nNote that this function cannot correctly handle binary files\n(specifically, files containing C<\\0> character which is treated\nas end of line). For those you need to use the C\nfunction which has a more complex interface."); else if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0) - pod2text ("aug-init - create a new Augeas handle", " aug-init \n\nCreate a new Augeas handle for editing configuration files.\nIf there was any previous Augeas handle associated with this\nguestfs session, then it is closed.\n\nYou must call this before using any other C\ncommands.\n\nC is the filesystem root. C must not be NULL,\nuse C instead.\n\nThe flags are the same as the flags defined in\nEaugeas.hE, the logical I of the following\nintegers:\n\n=over 4\n\n=item 1 C\n\nKeep the original file with a C<.augsave> extension.\n\n=item 2 C\n\nSave changes into a file with extension C<.augnew>, and\ndo not overwrite original. Overrides C.\n\n=item 4 C\n\nTypecheck lenses (can be expensive).\n\n=item 8 C\n\nDo not use standard load path for modules.\n\n=item 16 C\n\nMake save a no-op, just record what would have been changed.\n\n=item 32 C\n\nDo not load the tree in C.\n\n=back\n\nTo close the handle, you can call C.\n\nTo find out more about Augeas, see L."); + pod2text ("aug-init - create a new Augeas handle", " aug-init \n\nCreate a new Augeas handle for editing configuration files.\nIf there was any previous Augeas handle associated with this\nguestfs session, then it is closed.\n\nYou must call this before using any other C\ncommands.\n\nC is the filesystem root. C must not be NULL,\nuse C instead.\n\nThe flags are the same as the flags defined in\nEaugeas.hE, the logical I of the following\nintegers:\n\n=over 4\n\n=item C = 1\n\nKeep the original file with a C<.augsave> extension.\n\n=item C = 2\n\nSave changes into a file with extension C<.augnew>, and\ndo not overwrite original. Overrides C.\n\n=item C = 4\n\nTypecheck lenses (can be expensive).\n\n=item C = 8\n\nDo not use standard load path for modules.\n\n=item C = 16\n\nMake save a no-op, just record what would have been changed.\n\n=item C = 32\n\nDo not load the tree in C.\n\n=back\n\nTo close the handle, you can call C.\n\nTo find out more about Augeas, see L."); else if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0) pod2text ("aug-close - close the current Augeas handle", " aug-close\n\nClose the current Augeas handle and free up any resources\nused by it. After calling this, you have to call\nC again before you can use any other\nAugeas functions."); @@ -188,6 +189,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0) pod2text ("aug-load - load files into the tree", " aug-load\n\nLoad files into the tree.\n\nSee C in the Augeas documentation for the full gory\ndetails."); else + if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0) + pod2text ("aug-ls - list Augeas nodes under a path", " aug-ls \n\nThis is just a shortcut for listing C\nC and sorting the resulting nodes into alphabetical order."); + else display_builtin_command (cmd); } @@ -867,6 +871,23 @@ static int run_aug_load (const char *cmd, int argc, char *argv[]) return r; } +static int run_aug_ls (const char *cmd, int argc, char *argv[]) +{ + char **r; + const char *path; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + path = argv[0]; + r = guestfs_aug_ls (g, path); + if (r == NULL) return -1; + print_strings (r); + free_strings (r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -983,6 +1004,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0) return run_aug_load (cmd, argc, argv); else + if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0) + return run_aug_ls (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1;