Skip to content

Commit

Permalink
chore(cli): add cli structure to the project
Browse files Browse the repository at this point in the history
Refs: #436
  • Loading branch information
piraz committed Jun 16, 2023
1 parent 2e2fbed commit dd675f4
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
21 changes: 21 additions & 0 deletions firenado/bin/firenado-cli1.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions firenado/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .root import firenado_cli
16 changes: 16 additions & 0 deletions firenado/cli/commands.py
Original file line number Diff line number Diff line change
@@ -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.

12 changes: 12 additions & 0 deletions firenado/cli/root.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions firenado/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions tests/features/cli.feature
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions tests/features/steps/cli.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit dd675f4

Please sign in to comment.