Skip to content

Commit

Permalink
📌 ISSUE-#2 - Command to show some settings
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoCelmer committed Mar 15, 2023
1 parent a36a89e commit cb81c40
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
22 changes: 22 additions & 0 deletions linux_profile_plugin/commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from linux_profile.base.settings import Settings
from linux_profile.base.command import Command


Expand All @@ -7,3 +8,24 @@ def execute(self):
"""Method for initializing custom commands.
"""
print("Hello World!", (self.arguments.message or ""))


class Explore(Command):

def execute(self):
"""Method for initializing custom commands.
"""
settings = Settings()
configs = [
"file_aliases",
"file_bashrc",
"path_config",
"path_install",
"path_profile",
"path_temp",
"file_config",
"file_profile"]

for config in configs:
if hasattr(settings, config):
print(f"{config}:".rjust(15), getattr(settings, config))
12 changes: 11 additions & 1 deletion linux_profile_plugin/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from linux_profile.main import BuildCommand
from linux_profile.base.command import BaseCommand
from linux_profile_plugin.commands import HelloWorld
from linux_profile_plugin.commands import HelloWorld, Explore


class ArgsCommand(BaseCommand):
Expand All @@ -11,13 +11,22 @@ def __init__(self, parser):
# "hello" command launcher.
self.setup_hello()

# "explore" command launcher.
self.setup_explore()

def setup_hello(self):
"""Argument loading method for the new command.
"""
self.cmd_hello = self.subparsers.add_parser('hello', help="My custom command")
self.cmd_hello = self.cmd_hello.add_argument_group('Usage: linuxp hello [OPTIONS]')
self.cmd_hello.add_argument('--message')

def setup_explore(self):
"""Argument loading method for the new command.
"""
self.cmd_explore = self.subparsers.add_parser('explore', help="My custom command")
self.cmd_explore = self.cmd_explore.add_argument_group('Usage: linuxp explore [OPTIONS]')


class Build(BuildCommand):

Expand All @@ -27,6 +36,7 @@ def setup(self) -> str:
"""Method for initializing custom commands.
"""
self.command.cmd_hello.set_defaults(exec=HelloWorld)
self.command.cmd_explore.set_defaults(exec=Explore)


def main():
Expand Down
12 changes: 11 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from linux_profile.main import BuildCommand
from linux_profile.base.command import BaseCommand
from linux_profile_plugin.commands import HelloWorld
from linux_profile_plugin.commands import HelloWorld, Explore


class ArgsCommand(BaseCommand):
Expand All @@ -11,13 +11,22 @@ def __init__(self, parser):
# "hello" command launcher.
self.setup_hello()

# "explore" command launcher.
self.setup_explore()

def setup_hello(self):
"""Argument loading method for the new command.
"""
self.cmd_hello = self.subparsers.add_parser('hello', help="My custom command")
self.cmd_hello = self.cmd_hello.add_argument_group('Usage: linuxp hello [OPTIONS]')
self.cmd_hello.add_argument('--message')

def setup_explore(self):
"""Argument loading method for the new command.
"""
self.cmd_explore = self.subparsers.add_parser('explore', help="This command shows some settings")
self.cmd_explore = self.cmd_explore.add_argument_group('Usage: linuxp explore [OPTIONS]')


class Build(BuildCommand):

Expand All @@ -27,6 +36,7 @@ def setup(self) -> str:
"""Method for initializing custom commands.
"""
self.command.cmd_hello.set_defaults(exec=HelloWorld)
self.command.cmd_explore.set_defaults(exec=Explore)


def main():
Expand Down

0 comments on commit cb81c40

Please sign in to comment.