jpcli 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jpcli-0.1.1/jpcli.egg-info → jpcli-0.1.2}/PKG-INFO +1 -1
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/main.py +15 -4
- {jpcli-0.1.1 → jpcli-0.1.2/jpcli.egg-info}/PKG-INFO +1 -1
- {jpcli-0.1.1 → jpcli-0.1.2}/setup.py +1 -1
- {jpcli-0.1.1 → jpcli-0.1.2}/LICENCE +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/MANIFEST.in +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/README.md +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/__init__.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/parsers/__init__.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/parsers/free_parser.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/parsers/lsmem_parser.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli/parsers/other_command_parser.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli.egg-info/SOURCES.txt +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli.egg-info/dependency_links.txt +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli.egg-info/entry_points.txt +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/jpcli.egg-info/top_level.txt +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/setup.cfg +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/tests/__init__.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/tests/test_lsmem_parser.py +0 -0
- {jpcli-0.1.1 → jpcli-0.1.2}/tests/test_other_command_parser.py +0 -0
@@ -23,12 +23,23 @@ def parse_command_output(command_output, parser_name):
|
|
23
23
|
def main():
|
24
24
|
parser = argparse.ArgumentParser(description='JP - JSON Parser for Linux commands')
|
25
25
|
parser.add_argument('command', type=str, help='The Linux command to run')
|
26
|
-
parser.add_argument('parser_name', type=str, nargs='?', default=
|
26
|
+
parser.add_argument('parser_name', type=str, nargs='?', default=None, help='The name of the parser to use')
|
27
27
|
|
28
28
|
args = parser.parse_args()
|
29
29
|
result = jpcli(args.command, args.parser_name)
|
30
30
|
print(result)
|
31
31
|
|
32
|
-
def jpcli(command, parser_name):
|
33
|
-
|
34
|
-
|
32
|
+
def jpcli(command, parser_name=None):
|
33
|
+
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
34
|
+
if result.returncode != 0:
|
35
|
+
print(f"Error: {result.stderr}", file=sys.stderr)
|
36
|
+
sys.exit(result.returncode)
|
37
|
+
|
38
|
+
command_output = result.stdout
|
39
|
+
if parser_name is None:
|
40
|
+
parser_name = command.split()[0] # Use the first word of the command as the parser name
|
41
|
+
return parse_command_output(command_output, parser_name)
|
42
|
+
|
43
|
+
if __name__ == '__main__':
|
44
|
+
main()
|
45
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|