Files
Arnaud G. GIBERT cc7eda3588 - Base library:
- Rename default.bash to base.bash,
    - Normalise some function names: version_print(), help_print(), str_quote(), str_escape(), echo_line(), echo_error() & cmd_exec()
    - Normalise some global variables: VERBOSE & DRY_RUN,
    - Add default options: errexit, pipefail & nounset,
    - Add GPL headers,
- ISL:
    - Move ISL functions to isl command,
    - Add bash completion,
- URPMI-Setup:
    - Add urpmi-setup command.
2026-04-06 17:56:11 +02:00

64 lines
2.0 KiB
Bash

#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# ISL: Image Stack Log
#
# Copyright (C) 2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
_isl() {
local cur prev opts sub_opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help -h --version -V --test -T --verbose -v --add -a --cat -c --dump -d --top -t"
sub_opts="--reverse -r --inline -i --image -m"
# Check if we're completing a sub-option
case "${COMP_WORDS[1]}" in
--cat|-c|--dump|-d|--top|-t)
COMPREPLY=( $(compgen -W "${sub_opts}" -- "${cur}") )
return 0
;;
esac
# Top-level completion
case "${prev}" in
--add|-a)
COMPREPLY=( $(compgen -f -- "${cur}") ) # Complete with filenames/URLs
return 0
;;
--cat|-c|--dump|-d|--top|-t)
COMPREPLY=( $(compgen -W "${sub_opts}" -- "${cur}") )
return 0
;;
*)
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
}
complete -F _isl isl