Skip to content

Move commandline interface to typer #2751

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ install:
done
# completion
install -d -m 755 ${buildroot}usr/share/bash-completion/completions
$(python) helper/completion_generator.py \
> ${buildroot}usr/share/bash-completion/completions/kiwi-ng
install -m 644 completions/bash-completion \
${buildroot}usr/share/bash-completion/completions/kiwi-ng
# kiwi default configuration
install -d -m 755 ${buildroot}etc
install -m 644 kiwi.yml ${buildroot}etc/kiwi.yml
Expand Down Expand Up @@ -80,16 +80,6 @@ valid:
fi \
done

git_attributes:
# the following is required to update the $Format:%H$ git attribute
# for details on when this target is called see setup.py
git archive HEAD kiwi/version.py | tar -x

clean_git_attributes:
# cleanup version.py to origin state
# for details on when this target is called see setup.py
git checkout kiwi/version.py

setup:
poetry install --all-extras

Expand Down Expand Up @@ -162,7 +152,7 @@ prepare_for_pypi: clean setup
# ci-publish-to-pypi.yml github action
poetry build --format=sdist

clean: clean_git_attributes
clean:
rm -rf dist
rm -rf doc/build
rm -rf doc/dist
86 changes: 86 additions & 0 deletions completions/bash-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#========================================
# _kiwi
#----------------------------------------
function setupCompletionLine {
local comp_line=$(echo $COMP_LINE | sed -e 's@kiwi-ng@kiwi@')
local result_comp_line
local prev_was_option=0
for item in $comp_line; do
if [ $prev_was_option = 1 ];then
prev_was_option=0
continue
fi
if [[ $item =~ -.* ]];then
prev_was_option=1
continue
fi
result_comp_line="$result_comp_line $item"
done
echo $result_comp_line
}

function _kiwi {
local cur prev opts
_get_comp_words_by_ref cur prev
local cmd=$(setupCompletionLine | awk -F ' ' '{ print $NF }')
for comp in $prev $cmd;do
case "$comp" in
"image")
__comp_reply "info resize"
return 0
;;
"result")
__comp_reply "bundle list"
return 0
;;
"system")
__comp_reply "build create prepare update"
return 0
;;
"build")
__comp_reply "--add-bootstrap-package --add-container-label --add-package --add-repo --add-repo-credentials --allow-existing-root --clear-cache --delete-package --description --help --ignore-repos --ignore-repos-used-for-build --set-container-derived-from --set-container-tag --set-release-version --set-repo --set-repo-credentials --set-type-attr=<attribute --signing-key --target-dir help"
return 0
;;
"bundle")
__comp_reply "--bundle-dir --bundle-format --help --id --package-as-rpm --target-dir --zsync-source help"
return 0
;;
"create")
__comp_reply "--help --root --signing-key --target-dir help"
return 0
;;
"info")
__comp_reply "--description --help --list-profiles --resolve-package-list help"
return 0
;;
"list")
__comp_reply "--help --target-dir help"
return 0
;;
"prepare")
__comp_reply "--add-bootstrap-package --add-container-label --add-package --add-repo --add-repo-credentials --allow-existing-root --clear-cache --delete-package --description --help --ignore-repos --ignore-repos-used-for-build --root --set-container-derived-from --set-container-tag --set-release-version --set-repo --set-repo-credentials --set-type-attr=<attribute --signing-key help"
return 0
;;
"resize")
__comp_reply "--help --root --size --target-dir help"
return 0
;;
"update")
__comp_reply "--add-package --delete-package --help --root help"
return 0
;;
esac
done
__comp_reply "--help --logfile --profile --version help image result system"
return 0
}
#========================================
# comp_reply
#----------------------------------------
function __comp_reply {
word_list=$@
COMPREPLY=($(compgen -W "$word_list" -- ${cur}))
}

complete -F _kiwi -o default kiwi
complete -F _kiwi -o default kiwi-ng
3 changes: 1 addition & 2 deletions doc/source/commands/image_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng image info -h | --help
kiwi-ng image info --help
kiwi-ng image info --description=<directory>
[--resolve-package-list]
[--list-profiles]
[--print-kiwi-env]
[--ignore-repos]
[--add-repo=<source,type,alias,priority>...]
[--print-xml|--print-yaml]
kiwi-ng image info help

.. _db_image_info_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/image_resize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng image resize -h | --help
kiwi-ng image resize --help
kiwi-ng image resize --target-dir=<directory> --size=<size>
[--root=<directory>]
kiwi-ng image resize help

.. _db_kiwi_image_resize_desc:

Expand Down
50 changes: 9 additions & 41 deletions doc/source/commands/kiwi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,13 @@ SYNOPSIS

.. code:: bash

kiwi-ng [global options] service <command> [<args>]

kiwi-ng -h | --help
kiwi-ng [--profile=<name>...]
[--temp-dir=<directory>]
[--type=<build_type>]
[--logfile=<filename>]
[--logsocket=<socketfile>]
[--loglevel=<number>]
[--debug]
[--debug-run-scripts-in-screen]
[--color-output]
[--config=<configfile>]
[--kiwi-file=<kiwifile>]
image <command> [<args>...]
kiwi-ng [--logfile=<filename>]
[--logsocket=<socketfile>]
[--loglevel=<number>]
[--debug]
[--debug-run-scripts-in-screen]
[--color-output]
[--config=<configfile>]
result <command> [<args>...]
kiwi-ng [--profile=<name>...]
[--shared-cache-dir=<directory>]
[--temp-dir=<directory>]
[--target-arch=<name>]
[--type=<build_type>]
[--logfile=<filename>]
[--logsocket=<socketfile>]
[--loglevel=<number>]
[--debug]
[--debug-run-scripts-in-screen]
[--color-output]
[--config=<configfile>]
[--kiwi-file=<kiwifile>]
system <command> [<args>...]
kiwi-ng -v | --version
kiwi-ng help
kiwi-ng --help | --version

kiwi-ng [global options] image <command> [<args>...]
kiwi-ng [global options] result <command> [<args>...]
kiwi-ng [global options] system <command> [<args>...]

kiwi-ng help [kiwi::COMMAND::SUBCOMMAND]

.. _db_commands_kiwi_desc:

Expand Down Expand Up @@ -95,8 +63,8 @@ GLOBAL OPTIONS
--config=<configfile>

Use specified runtime configuration file. If not specified, the
runtime configuration is expected to be in the :file:`~/.config/kiwi/config.yml`
or :file:`/etc/kiwi.yml` files.
runtime configuration is expected to be in the
:file:`~/.config/kiwi/config.yml` or :file:`/etc/kiwi.yml` files.

--debug

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/result_bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng result bundle -h | --help
kiwi-ng result bundle --help
kiwi-ng result bundle --target-dir=<directory> --id=<bundle_id> --bundle-dir=<directory>
[--bundle-format=<format>]
[--zsync_source=<download_location>]
[--package-as-rpm]
kiwi-ng result bundle help

.. _db_kiwi_result_bundle_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/result_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng result list -h | --help
kiwi-ng result list --help
kiwi-ng result list --target-dir=<directory>
kiwi-ng result list help

.. _db_kiwi_result_list_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/system_build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng system build -h | --help
kiwi-ng system build --help
kiwi-ng system build --description=<directory> --target-dir=<directory>
[--allow-existing-root]
[--clear-cache]
Expand All @@ -31,7 +31,6 @@ SYNOPSIS
[--set-type-attr=<attribute=value>...]
[--set-release-version=<version>]
[--signing-key=<key-file>...]
kiwi-ng system build help

.. _db_kiwi_system_build_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/system_create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng system create -h | --help
kiwi-ng system create --help
kiwi-ng system create --root=<directory> --target-dir=<directory>
[--signing-key=<key-file>...]
kiwi-ng system create help

.. _db_kiwi_system_create_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/system_prepare.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng system prepare -h | --help
kiwi-ng system prepare --help
kiwi-ng system prepare --description=<directory> --root=<directory>
[--allow-existing-root]
[--clear-cache]
Expand All @@ -29,7 +29,6 @@ SYNOPSIS
[--set-type-attr=<attribute=value>...]
[--set-release-version=<version>]
[--signing-key=<key-file>...]
kiwi-ng system prepare help

.. _db_kiwi_system_prepare_desc:

Expand Down
3 changes: 1 addition & 2 deletions doc/source/commands/system_update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ SYNOPSIS

kiwi-ng [global options] service <command> [<args>]

kiwi-ng system update -h | --help
kiwi-ng system update --help
kiwi-ng system update --root=<directory>
[--add-package=<name>...]
[--delete-package=<name>...]
kiwi-ng system update help

.. _db_kiwi_system_update_desc:

Expand Down
17 changes: 0 additions & 17 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@
'sphinx_rtd_theme'
]

docopt_ignore = [
'kiwi.cli',
'kiwi.tasks.system_build',
'kiwi.tasks.system_prepare',
'kiwi.tasks.system_update',
'kiwi.tasks.system_create',
'kiwi.tasks.result_list',
'kiwi.tasks.result_bundle',
'kiwi.tasks.image_resize',
'kiwi.tasks.image_info'
]

def remove_module_docstring(app, what, name, obj, options, lines):
if what == "module" and name in docopt_ignore:
del lines[:]

def prologReplace(app, docname, source):
result = source[0]
for key in app.config.prolog_replacements:
Expand All @@ -60,7 +44,6 @@ def prologReplace(app, docname, source):
def setup(app):
app.add_config_value('prolog_replacements', {}, True)
app.connect('source-read', prologReplace)
app.connect("autodoc-process-docstring", remove_module_docstring)


prolog_replacements = {
Expand Down
11 changes: 9 additions & 2 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,20 @@ Create a Python Virtual Development Environment
-----------------------------------------------

The following commands initializes and activates a development
environment for Python 3:
environment for the current default Python version:

.. code:: shell-session

$ poetry install

.. note::

To create the python virtual env for another version of
Python, e.g. 3.11, call the following prior the poetry install
::

$ poetry env use python3.11

The command above automatically creates the application script
called :command:`kiwi-ng`, which allows you to run {kiwi} from the
Python sources inside the virtual environment using Poetry:
Expand All @@ -76,7 +84,6 @@ Python sources inside the virtual environment using Poetry:

$ poetry run kiwi-ng --help


Running the Unit Tests
----------------------

Expand Down
Loading
Loading