Skip to content

Commit f17cd0e

Browse files
⚙️ FEATURE: CLI Project
1 parent 08c7283 commit f17cd0e

File tree

5 files changed

+168
-0
lines changed

5 files changed

+168
-0
lines changed

linux_dev/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
__version__ = "0.0.1"
2+
3+
__author__ = 'Fernando Celmer <email@fernandocelmer.com>'
4+
__copyright__ = """MIT License
5+
6+
Copyright (c) 2023 Linux Profile
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE."""
25+
26+
27+
__info__ = """
28+
Help: linuxd --help
29+
Docs: https://docs.linuxprofile.com/
30+
=====================================
31+
"""

linux_dev/commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from linux_profile.base.command import Command
2+
3+
4+
class HelloWorld(Command):
5+
6+
def execute(self):
7+
"""Method for initializing custom commands.
8+
"""
9+
print("Hello World!", (self.arguments.message or ""))

linux_dev/main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from linux_profile.main import BuildCommand
2+
from linux_profile.base.command import BaseCommand
3+
from linux_dev.commands import HelloWorld
4+
5+
6+
class ArgsCommand(BaseCommand):
7+
8+
def __init__(self, parser):
9+
super().__init__(parser)
10+
11+
# "hello" command launcher.
12+
self.setup_hello()
13+
14+
def setup_hello(self):
15+
"""Argument loading method for the new command.
16+
"""
17+
self.cmd_hello = self.subparsers.add_parser('hello', help="My custom command")
18+
self.cmd_hello = self.cmd_hello.add_argument_group('Usage: linuxd hello [OPTIONS]')
19+
self.cmd_hello.add_argument('--message')
20+
21+
22+
class Build(BuildCommand):
23+
24+
base_command = ArgsCommand
25+
26+
def setup(self) -> str:
27+
"""Method for initializing custom commands.
28+
"""
29+
self.command.cmd_hello.set_defaults(exec=HelloWorld)
30+
31+
32+
def main():
33+
Build()
34+
35+
36+
if __name__ == '__main__':
37+
main()

main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from linux_profile.main import BuildCommand
2+
from linux_profile.base.command import BaseCommand
3+
from linux_dev.commands import HelloWorld
4+
5+
6+
class ArgsCommand(BaseCommand):
7+
8+
def __init__(self, parser):
9+
super().__init__(parser)
10+
11+
# "hello" command launcher.
12+
self.setup_hello()
13+
14+
def setup_hello(self):
15+
"""Argument loading method for the new command.
16+
"""
17+
self.cmd_hello = self.subparsers.add_parser('hello', help="My custom command")
18+
self.cmd_hello = self.cmd_hello.add_argument_group('Usage: linuxp hello [OPTIONS]')
19+
self.cmd_hello.add_argument('--message')
20+
21+
22+
class Build(BuildCommand):
23+
24+
base_command = ArgsCommand
25+
26+
def setup(self) -> str:
27+
"""Method for initializing custom commands.
28+
"""
29+
self.command.cmd_hello.set_defaults(exec=HelloWorld)
30+
31+
32+
def main():
33+
Build()
34+
35+
36+
if __name__ == '__main__':
37+
main()

setup.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
from linux_dev import __version__
5+
6+
from setuptools import setup
7+
from setuptools.command.install import install
8+
9+
10+
with open("README.md", "r", encoding="utf-8") as fh:
11+
long_description = fh.read()
12+
13+
14+
class CustomInstallCommand(install):
15+
def run(self):
16+
install.run(self)
17+
18+
19+
setup(
20+
name="linuxd",
21+
version=__version__,
22+
author="Fernando Celmer",
23+
author_email="email@fernandocelmer.com",
24+
description="🐧 Dev Linux Profile",
25+
long_description=long_description,
26+
long_description_content_type="text/markdown",
27+
url="https://github.com/linux-profile/linux-dev",
28+
cmdclass={
29+
'install': CustomInstallCommand,
30+
},
31+
install_requires=[
32+
'linuxp>=1.0.19'
33+
],
34+
classifiers=[
35+
'Development Status :: 4 - Beta',
36+
"Operating System :: OS Independent",
37+
"License :: OSI Approved :: MIT License",
38+
'Intended Audience :: Developers',
39+
'Natural Language :: English',
40+
"Programming Language :: Python :: 3.6",
41+
"Programming Language :: Python :: 3.7",
42+
"Programming Language :: Python :: 3.8",
43+
"Programming Language :: Python :: 3.9",
44+
"Programming Language :: Python :: 3.10",
45+
"Programming Language :: Python :: 3.11",
46+
],
47+
include_package_data=True,
48+
python_requires=">=3.6",
49+
zip_safe=True,
50+
fullname='linuxd',
51+
entry_points={
52+
'console_scripts': ['linuxd=linux_dev.main:main'],
53+
},
54+
)

0 commit comments

Comments
 (0)