Add basic cli

Signed-off-by: Charles Short <charles.short@windriver.com>
This commit is contained in:
Charles Short 2023-07-19 09:14:36 -04:00
parent f0baba8784
commit 53d11855ad
9 changed files with 68 additions and 29 deletions

View File

25
apt_ostree/cmd/shell.py Normal file
View File

@ -0,0 +1,25 @@
"""
Copyright (c) 2023 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
import click
from apt_ostree.cmd.version import version
@click.group(
help="\nHyrbid image/package management system."
)
@click.pass_context
def cli(ctx: click.Context):
ctx.ensure_object(dict)
def main():
cli(prog_name="apt-ostree")
cli.add_command(version)

16
apt_ostree/cmd/version.py Normal file
View File

@ -0,0 +1,16 @@
"""
Copyright (c) 2023 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
import click
from apt_ostree.constants import VERSION
@click.command(name="version", help="Show version and exit.")
@click.pass_context
def version(ctxt):
print(VERSION)

8
apt_ostree/constants.py Normal file
View File

@ -0,0 +1,8 @@
"""
Copyright (c) 2023 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
VERSION = "0.1"

View File

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
test_apt_ostree
----------------------------------
Tests for `apt_ostree` module.
"""
from apt_ostree.tests import base
class TestApt_ostree(base.TestCase):
def test_something(self):
pass

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from apt_ostree.tests import base
from apt_ostree.cmd.shell import cli
from click.testing import CliRunner
class Test_apt_cli(base.TestCase):
def test_something(self):
runner = CliRunner()
result = runner.invoke(cli, ["version"])
assert result.exit_code == 0

View File

@ -57,7 +57,7 @@ copyright = '2022, OpenStack Developers'
# openstackdocstheme options
openstackdocs_repo_name = 'starlingx/apt-ostree'
openstackdocs_bug_project = 'replace with the name of the project on Launchpad or the ID from Storyboard'
openstackdocs_bug_project = ''
openstackdocs_bug_tag = ''
openstackdocs_auto_name = 'False'

View File

@ -21,6 +21,10 @@ classifier =
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
[entry_points]
console_scripts =
apt-ostree = apt_ostree.cmd.shell:main
[files]
packages =
apt_ostree

View File

@ -9,3 +9,4 @@ python-subunit>=0.0.18 # Apache-2.0/BSD
oslotest>=1.10.0 # Apache-2.0
stestr>=1.0.0 # Apache-2.0
testtools>=1.4.0 # MIT
click