Merge branch 'align-completely-to-fire-cli' into 'master'
Align completely to fire cli See merge request icaotix/linux-tools!16
This commit is contained in:
commit
6a90c0fa90
@ -1,12 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractModule(ABC):
|
|
||||||
"""docstring for Module."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(AbstractModule, self).__init__()
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def run(self):
|
|
||||||
pass
|
|
@ -10,7 +10,7 @@ then
|
|||||||
pip3 install setuptools wheel regex
|
pip3 install setuptools wheel regex
|
||||||
cd $DIR
|
cd $DIR
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
python3 main.py helloworld run
|
python3 main.py helloworld
|
||||||
else
|
else
|
||||||
cd $DIR
|
cd $DIR
|
||||||
python3 main.py "$@"
|
python3 main.py "$@"
|
27
main.py
27
main.py
@ -1,20 +1,17 @@
|
|||||||
import importlib
|
|
||||||
import os
|
|
||||||
import fire
|
import fire
|
||||||
|
|
||||||
|
from modules.helloworld.HelloWorld import HelloWorld
|
||||||
|
from modules.install.ToolsInstaller import ToolsInstaller
|
||||||
|
from modules.swap.SwapModule import SwapModule
|
||||||
|
from modules.systemupdate.Systemupdate import Systemupdate
|
||||||
|
from modules.vim.VimModule import VimModule
|
||||||
|
|
||||||
def load_modules():
|
modules = {
|
||||||
print("Loading modules")
|
"helloworld": HelloWorld().run,
|
||||||
loaded_modules = {}
|
"install": ToolsInstaller,
|
||||||
for folder in os.listdir("./modules"):
|
"swap": SwapModule().run,
|
||||||
try:
|
"update": Systemupdate().run,
|
||||||
curr_module = importlib.import_module('.' + folder, package="modules")
|
"vim": VimModule().run
|
||||||
loaded_modules[folder] = curr_module.get_module()
|
}
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
print("Modules loaded successfully.\n")
|
|
||||||
return loaded_modules
|
|
||||||
|
|
||||||
|
|
||||||
modules = load_modules()
|
|
||||||
fire.Fire(modules)
|
fire.Fire(modules)
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from AbstractModule import AbstractModule
|
class HelloWorld:
|
||||||
|
|
||||||
|
|
||||||
class HelloWorld(AbstractModule):
|
|
||||||
"""docstring for SampleModule."""
|
"""docstring for SampleModule."""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(HelloWorld, self).__init__()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print("This shows that your installation is working correctly.")
|
print("This shows that your installation is working correctly.")
|
||||||
print("You can now start using the tool.")
|
print("You can now start using the tool.")
|
@ -1,5 +0,0 @@
|
|||||||
from .helloWorld import HelloWorld
|
|
||||||
|
|
||||||
|
|
||||||
def get_module():
|
|
||||||
return HelloWorld()
|
|
@ -1,17 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from AbstractModule import AbstractModule
|
|
||||||
|
|
||||||
|
class ToolsInstaller:
|
||||||
class CmdToolsModule(AbstractModule):
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
with open("modules/install/programs.json") as config_file:
|
||||||
with open("modules/program-installer/programs.json") as config_file:
|
|
||||||
self.programs_json = json.load(config_file)
|
self.programs_json = json.load(config_file)
|
||||||
|
|
||||||
def run(self):
|
def basic_tools(self):
|
||||||
"""Install the most basic tools!"""
|
"""Install the most basic tools!"""
|
||||||
print("Try to install basic Command-line tools")
|
print("Try to install basic Command-line tools")
|
||||||
|
|
0
modules/install/__init__.py
Normal file
0
modules/install/__init__.py
Normal file
@ -1,5 +0,0 @@
|
|||||||
from .module import CmdToolsModule
|
|
||||||
|
|
||||||
|
|
||||||
def get_module():
|
|
||||||
return CmdToolsModule()
|
|
@ -1,7 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from AbstractModule import AbstractModule
|
|
||||||
from PyInquirer import prompt
|
from PyInquirer import prompt
|
||||||
|
|
||||||
|
|
||||||
@ -9,10 +8,7 @@ def _run_shell_command(cmd: List[str]) -> str:
|
|||||||
return subprocess.check_output(cmd).decode("UTF-8").strip()
|
return subprocess.check_output(cmd).decode("UTF-8").strip()
|
||||||
|
|
||||||
|
|
||||||
class SwapModule(AbstractModule):
|
class SwapModule:
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
actions = {
|
actions = {
|
@ -1,5 +0,0 @@
|
|||||||
from .module import SwapModule
|
|
||||||
|
|
||||||
|
|
||||||
def get_module():
|
|
||||||
return SwapModule()
|
|
@ -1,9 +1,7 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from AbstractModule import AbstractModule
|
|
||||||
|
|
||||||
|
class Systemupdate:
|
||||||
class Systemupdate(AbstractModule):
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print("Running update")
|
print("Running update")
|
@ -1,5 +0,0 @@
|
|||||||
from .systemupdate import Systemupdate
|
|
||||||
|
|
||||||
|
|
||||||
def get_module():
|
|
||||||
return Systemupdate()
|
|
@ -5,10 +5,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
from PyInquirer import prompt
|
from PyInquirer import prompt
|
||||||
|
|
||||||
from AbstractModule import AbstractModule
|
|
||||||
|
|
||||||
|
class VimModule:
|
||||||
class VimModule(AbstractModule):
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._debugFlag = False
|
self._debugFlag = False
|
@ -1,5 +0,0 @@
|
|||||||
from .module import VimModule
|
|
||||||
|
|
||||||
|
|
||||||
def get_module():
|
|
||||||
return VimModule()
|
|
Loading…
Reference in New Issue
Block a user