diff --git a/jc/jc.py b/jc/jc.py index 25e89f85..1f7830cb 100755 --- a/jc/jc.py +++ b/jc/jc.py @@ -68,12 +68,26 @@ def helptext(message): Example: ls -al | jc --ls -p - ''' print(textwrap.dedent(helptext_string), file=sys.stderr) +def errormessage(message): + error_string = f''' + jc: {message} + ''' + + print(textwrap.dedent(error_string), file=sys.stderr) + + +def compatibility(mod_name, compatible): + if sys.platform not in compatible: + mod = mod_name.split('.')[-1] + errormessage(f'{mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compatible}') + exit() + + def main(): signal.signal(signal.SIGINT, ctrlc) diff --git a/jc/parsers/lsblk.py b/jc/parsers/lsblk.py index 2d9e8155..86730046 100644 --- a/jc/parsers/lsblk.py +++ b/jc/parsers/lsblk.py @@ -79,6 +79,7 @@ $ lsblk | jc --lsblk -p ] """ import string +import jc def process(proc_data): @@ -129,6 +130,9 @@ def process(proc_data): def parse(data, raw=False): + jc.jc.compatibility(__name__, + ['linux']) + raw_output = [] linedata = data.splitlines() # Clear any blank lines