builder: allow a specific template for --list

Allow the user to specify a template in --list mode, which will be the
only result in the resulting output (instead of all the available
templates).

This makes it easier to find out the details of a specific template.
This commit is contained in:
Pino Toscano
2016-01-14 12:40:31 +01:00
parent 0a84c67bd6
commit 0687bb8e07
3 changed files with 15 additions and 7 deletions

View File

@@ -213,6 +213,12 @@ let main () =
let mode =
match mode with
| `List -> (* --list *)
let sources, index =
match cmdline.arg with
| "" -> sources, index (* no template -> all the available ones *)
| arg -> (* just the specified template *)
let item = selected_cli_item cmdline index in
[], [item] in
List_entries.list_entries ~list_format:cmdline.list_format ~sources index;
exit 0

View File

@@ -239,9 +239,10 @@ read the man page virt-builder(1).
if format <> None then
error (f_"--list: use '--list-format', not '--format'");
(match args with
| [arg] -> arg
| [] -> ""
| _ ->
error (f_"--list option does not need any extra arguments")
error (f_"too many parameters, at most one 'os-version' is allowed for --list")
)
| `Notes ->
(match args with

View File

@@ -16,7 +16,7 @@ virt-builder - Build virtual machine images quickly
[--arch ARCHITECTURE] [--attach ISOFILE]
__CUSTOMIZE_SYNOPSIS__
virt-builder -l|--list [--long] [--list-format short|long|json]
virt-builder -l|--list [--long] [--list-format short|long|json] [os-version]
virt-builder --notes os-version
@@ -311,15 +311,16 @@ alternate home directory:
virt-builder --gpg "gpg --homedir /tmp" [...]
=item B<-l>
=item B<-l> [os-version]
=item B<--list>
=item B<--list> [os-version]
=item B<--list --list-format> format
=item B<--list --list-format> format [os-version]
=item B<--list --long>
=item B<--list --long> [os-version]
List available templates.
List all the available templates if no guest is specified, or only for the
specified one.
It is possible to choose with I<--list-format> the output format for the list
templates: