From bf457b0d49df13bff4762cf03c369031dc82556a Mon Sep 17 00:00:00 2001 From: Flavio Garcia Date: Wed, 14 Jun 2023 10:36:13 -0400 Subject: [PATCH] chore(cli): add cli structure to the project Refs: #436 --- firenado/bin/firenado-cli1.py | 21 +++++++++++++++++++++ firenado/cli/__init__.py | 1 + firenado/cli/commands.py | 16 ++++++++++++++++ firenado/cli/root.py | 12 ++++++++++++ firenado/conf/__init__.py | 3 +++ tests/features/cli.feature | 24 ++++++++++++++++++++++++ tests/features/steps/cli.py | 30 ++++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+) create mode 100644 firenado/bin/firenado-cli1.py create mode 100644 firenado/cli/__init__.py create mode 100644 firenado/cli/commands.py create mode 100644 firenado/cli/root.py create mode 100644 tests/features/cli.feature create mode 100644 tests/features/steps/cli.py diff --git a/firenado/bin/firenado-cli1.py b/firenado/bin/firenado-cli1.py new file mode 100644 index 0000000..cf03fd1 --- /dev/null +++ b/firenado/bin/firenado-cli1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +# +# Copyright 2015-2022 Flávio Gonçalves Garcia +# +# 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. + +from firenado.cli import firenado_cli + +if __name__ == "__main__": + firenado_cli() diff --git a/firenado/cli/__init__.py b/firenado/cli/__init__.py new file mode 100644 index 0000000..3be82cc --- /dev/null +++ b/firenado/cli/__init__.py @@ -0,0 +1 @@ +from .root import firenado_cli diff --git a/firenado/cli/commands.py b/firenado/cli/commands.py new file mode 100644 index 0000000..fef3cf8 --- /dev/null +++ b/firenado/cli/commands.py @@ -0,0 +1,16 @@ +# -*- coding: UTF-8 -*- +# +# Copyright 2015-2022 Flávio Gonçalves Garcia +# +# 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. + diff --git a/firenado/cli/root.py b/firenado/cli/root.py new file mode 100644 index 0000000..1dc9e90 --- /dev/null +++ b/firenado/cli/root.py @@ -0,0 +1,12 @@ +import click +import firenado.conf +import logging +import os +import taskio +from taskio import core +import sys + + +@taskio.root(taskio_conf=firenado.conf.taskio_conf) +def firenado_cli(ctx): + pass diff --git a/firenado/conf/__init__.py b/firenado/conf/__init__.py index 5922829..071cb2a 100644 --- a/firenado/conf/__init__.py +++ b/firenado/conf/__init__.py @@ -135,9 +135,12 @@ session['redis']['data']['source'] = "" session['type'] = "" +taskio_conf = {} + if HAS_LIB_CONFIG_FILE: lib_config = load_yaml_file(LIB_CONFIG_FILE) _config.process_config(sys.modules[__name__], lib_config) + taskio_conf = load_yaml_file(LIB_CONFIG_FILE) if HAS_SYS_CONFIG_FILE: sys_config = load_yaml_file(SYS_CONFIG_FILE) diff --git a/tests/features/cli.feature b/tests/features/cli.feature new file mode 100644 index 0000000..6122083 --- /dev/null +++ b/tests/features/cli.feature @@ -0,0 +1,24 @@ +# Copyright 2015-2022 Flávio Gonçalves Garcia +# +# 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. + +Feature: Command line + # A Firenado application is started by a launcher. Here we tests important + # scenarios related to launchers. + + Scenario: Create a new project + # Enter steps here + Given command "project init" is called + When The application is running correctly at 128393 port + Then We shutdown the process launcher + And The application stops successfully \ No newline at end of file diff --git a/tests/features/steps/cli.py b/tests/features/steps/cli.py new file mode 100644 index 0000000..8e5e761 --- /dev/null +++ b/tests/features/steps/cli.py @@ -0,0 +1,30 @@ +# -*- coding: UTF-8 -*- +# +# Copyright 2015-2022 Flávio Gonçalves Garcia +# +# 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. + + +from behave import given, when, then +from behave.api.async_step import async_run_until_complete +from tests import PROJECT_ROOT, chdir_fixture_app +from firenado.launcher import ProcessLauncher +from tornado import gen +from tornado.httpclient import AsyncHTTPClient +import sys + + +@given("command {command} is called") +async def command_is_called(context, command): + context.tester.assertTrue(False) + print("Buga")