Commit Graph

33 Commits

Author SHA1 Message Date
Stéphane Graber
4c8139f9cf
Remove autotools
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 00:46:59 -04:00
Antonio Terceiro
25d1b3fb09 bash: rename main bash completion file
Since the `lxc` binary is actually provided by lxd, the main
bash-completion file needs to be moved away to not conflict with a bash
completion file provided for the `lxc` binary by lxd.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
2022-05-12 10:47:18 -03:00
Stéphane Graber
4a858b5665
meson: Add bash completion
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-05-01 12:21:53 +02:00
Heinrich Schuchardt
07459c88d5 Add riscv64 to --arch parameter values
lxc-attach uses an --arch parameter. 'riscv64' should be a usable value.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-10-19 13:18:02 +02:00
Edênis Freindorfer Azevedo
d9be2feb09
Fix lxc-cgroup smart completion.
Also make bash function more readable for itself.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-08 10:40:49 -03:00
Edênis Freindorfer Azevedo
b3dcb19407
Refactor __lxc_check_name_present().
Print name of container found, if any.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
c227466673
Check completion for prefixes names.
If a name is a prefix of another word available for completion, adjust
to show all words with given prefix.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
83ca245532
Add __lxc_cgroup_state_object().
Support cgroup state-object completion values for `lxc-cgroup`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
d36b3a3a9a
Update _lxc_usernsexec.
Not really much can be done for this function, as `-m` requires an ID
mapping that has to be manually input, since it will use
`/etc/sub{g,u}id` if not specified.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
2b86aa4c23
Add completion for lxc-copy param --fssize.
Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
a33d86d20b
Add __lxc_get_selinux_contexts().
List SElinux contexts available. Not clear if this could be only for
root or if normal user with `sudo` is also supported.

Using `Fedora34` for basic testing.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
4cd0915e76
Refactor __lxc_groups() to __lxc_get_groups().
Make code logic be more clear to what it is being done.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:24:06 -03:00
Edênis Freindorfer Azevedo
f73bcca529
Another round of more bash-like syntax.
Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:57 -03:00
Edênis Freindorfer Azevedo
b73b4ec7fb
Fix lxc-create completion.
Do not append a name of an existing container.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:57 -03:00
Edênis Freindorfer Azevedo
d72a39a528
Add support for comma as a completion word.
For `lxc-ls --groups` and `lxc-autostart --groups`.
Support leading comma, trailing comma, embedded double comma.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:57 -03:00
Edênis Freindorfer Azevedo
66e8c08985
Refactor __lxc_piped_args.
Use bash functions for common array operations. Keep code logic somewhat
easy to read for bug hunting.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:57 -03:00
Edênis Freindorfer Azevedo
53431db944
Fix lxc-snapshot completion.
For options `-r,--restore` and `-d,--destroy`, we need the container
name to create the list of completion values.

Therefore, it is needed to scan the current command line to check if
there is a container name available.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:57 -03:00
Edênis Freindorfer Azevedo
8617586740
Use more bash-like syntax.
Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-07 22:23:46 -03:00
Edênis Freindorfer Azevedo
6139460643
Add support for container composed names.
When a container name has whitespace in it
(e.g. created by `lxc-create -t download -n "arch linux"` ),
the completion for other commands should be able to work by adding a
backslash to escape it.

Although it may be interesting to support names between quotes, this
would probably means to have to add quotes to all names. Might not be
interesting just due to an edge case.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
8e4c68e67a
Add completion output for lxc-ls --fancy-format.
Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
8aa4490505
Improve name completion handling.
Use regex to handle short option `-n`, since short options can be
combined (e.g. `-nd`) as long as at max one requires an argument.

Also consider the case when the arg for the long option is not given
together with `--name=`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
db8b9df555
Add compopt call to __lxc_piped_args.
On pair with how other functions do it. Also, be smarter about adding
whitespace when there are no more completions available for the
parameter.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
2173e808ca
Use --running instead of --active.
Commands block if container is frozen.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
4246469f8b
Fill missing commands on name completion.
Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
2021-09-06 17:00:32 -03:00
Edênis Freindorfer Azevedo
35a5efc917
Improve bash completion.
Use as much as possible from each command `--help` for completion.

Some options require a long list of completions that should be dumped by
some command option. These are not added here yet.

Examples of those are: `lxc-info --config`, `lxc-execute --define` and
`lxc-start --define`.

Signed-off-by: Edenis Freindorfer Azevedo <edenisfa@gmail.com>
2021-07-06 22:50:24 -03:00
Christian Brauner
a9145d622f
tree-wide: cleanup
- remove legacy binaries
- conditionalize creation of docs and tests for the command line tools and the
  shared library helper commands

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-28 10:05:33 +01:00
Abbas Ally
caba109477 Add bash completion to list backing store types for lxc-create -B
- Backing Store types are hard-coded (Not sure how to get programmatically)
- Closes #1236

Signed-off-by: Abbas Ally <abbasally5@yahoo.com>
2017-12-03 05:51:44 +00:00
Evgeni Golov
23f4c8a01a install bash completion where pkg-config tells us to
Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-11-12 14:57:34 +01:00
Christian Brauner
d0a6bd3940 configure.ac: add --enable-deprecated flag
- lxc-clone and lxc-start-ephemeral are marked deprecated. We add a
  --enable-deprecated flag to configure.ac allowing us to enable these
  deprecated executables
- update tests to use lxc-copy instead of lxc-clone

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-24 21:07:26 +01:00
Peter Simons
3db8dd39a7 bash completion: the 'have' command was deprecated in favor of '_have'
`bash-completion` version 2.1 and later no longer include the `have` command,
and consequently the `lxc` competion file fails on such systems. The command is
now called `_have`.

Signed-off-by: Peter Simons <simons@cryp.to>
2016-01-11 18:28:09 +01:00
Lucas Werkmeister
e0bc106769
Use POSIX-compliant function names in bash completion
When running in posix mode (for example, because it was invoked as `sh`,
or with the --posix option), bash rejects the function names previously
used because they contain hyphens, which are not legal POSIX names, and
exits immediately.

This is a particularly serious problem on a system in which the
following three conditions hold:

1. The `sh` executable is provided by bash, e. g. via a symlink
2. Gnome Display Manager is used to launch X sessions
3. Bash completion is loaded in the (system or user) profile file
   instead of in the bashrc file

In that case, GDM's Xsession script (run with `sh`, i. e., bash in posix
mode) sources the profile files, thus causing the shell to load the bash
completion files. Upon encountering the non-POSIX-compliant function
names, bash would then exit, immediately ending the X session.

Fixes #521.

Signed-off-by: Lucas Werkmeister <mail@lucaswerkmeister.de>
2015-05-14 22:39:06 +02:00
Johannes Kastl
c18d419f7c removed shebang from bash_completion-file
Signed-off-by: Johannes Kastl <git@ojkastl.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-03-03 10:57:41 -05:00
Stéphane Graber
0306de4f28 Add bash auto completion
This adds a basic bash auto-completion profile.

It supports 3 things at this time:
 - Auto-complete of container name (-n or -o)
 - Auto-complete of template name (-t)
 - Auto-complete of state names (-s)

It's configured in a way to be as little disruptive as possible, any
argument that's not explicitly handled by the profile will fallack to
bash's default completion.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 12:23:08 -05:00