1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

Merge pull request #1 from kellyjonbrazil/pr/44

Merge changes
This commit is contained in:
philippeitis
2020-03-08 14:10:35 -07:00
committed by GitHub
2 changed files with 12 additions and 5 deletions

View File

@ -188,7 +188,7 @@ def generate_magic_command(args):
Returns a tuple with a boolean and a command, where the boolean signifies that Returns a tuple with a boolean and a command, where the boolean signifies that
the command is valid, and the command is either a command string or None. the command is valid, and the command is either a command string or None.
""" """
# Parse with magic syntax: jc -p ls -al # Parse with magic syntax: jc -p ls -al
if len(args) <= 1 or args[1].startswith('--'): if len(args) <= 1 or args[1].startswith('--'):
return False, None return False, None

View File

@ -1,4 +1,3 @@
import os
import unittest import unittest
import jc.cli import jc.cli
@ -6,9 +5,17 @@ import jc.cli
class MyTests(unittest.TestCase): class MyTests(unittest.TestCase):
def test_cli(self): def test_cli(self):
commands = { commands = {
"jc -p systemctl list-sockets": "systemctl list-sockets | jc --systemctl-ls -p", 'jc -p systemctl list-sockets': 'systemctl list-sockets | jc --systemctl-ls -p',
"jc -p systemctl list-unit-files": "systemctl list-unit-files | jc --systemctl-luf -p", 'jc -p systemctl list-unit-files': 'systemctl list-unit-files | jc --systemctl-luf -p',
'jc -p pip list': 'pip list | jc --pip-list -p',
'jc -p pip3 list': 'pip3 list | jc --pip-list -p',
'jc -p pip show jc': 'pip show jc | jc --pip-show -p',
'jc -p pip3 show jc': 'pip3 show jc | jc --pip-show -p',
'jc -prd last': 'last | jc --last -prd',
'jc -prd lastb': 'lastb | jc --last -prd',
'jc -p nonexistent command': 'nonexistent command',
'jc -ap': None
} }
for command, expected_command in commands.items(): for command, expected_command in commands.items():
self.assertEquals(jc.cli.generate_magic_command(command.split(" "))[1], expected_command) self.assertEqual(jc.cli.generate_magic_command(command.split(' '))[1], expected_command)