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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jpcli
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A library to convert Linux command output to JSON
5
5
  Home-page: https://github.com/JaimeAdanCuevas/jpcli
6
6
  Author: Jaime Cuevas
@@ -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='', help='The name of the parser to use')
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
- output = run_command(command)
34
- return parse_command_output(output, parser_name)
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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jpcli
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A library to convert Linux command output to JSON
5
5
  Home-page: https://github.com/JaimeAdanCuevas/jpcli
6
6
  Author: Jaime Cuevas
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="jpcli",
8
- version="0.1.1",
8
+ version="0.1.2",
9
9
  author="Jaime Cuevas",
10
10
  author_email="adancuevas@outlook.com",
11
11
  description="A library to convert Linux command output to JSON",
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