Exemplo n.º 1
0
def main():
    main_inst = matuc_impl.main(TextFormatter())
    main_inst.run(sys.argv)
Exemplo n.º 2
0
                         '\n')

    def emit_usage(self, usage, error=None):
        if error:
            if not error.lower().startswith('error'):
                error = 'Error: ' + error
            print(error.rstrip(), end='\n\n')
        print(usage)

    def clear(self):
        """Clear the screen. There is no easy cross-platform way, so try to use
        cls/clear."""
        if sys.platform.startswith('win'):
            os.system('cmd /c cls')
        elif shutil.which('clear'):
            os.system('clear')
        else:
            print("\n" + "-" * matuc_impl.getTerminalSize()[0])
            if 'linux' in sys.platform:
                self.register_warning({
                    'message':
                    ("The `clear` command was not"
                     " found, install it, i.e. with `apt-get install ncurses-bin`."
                     )
                })


if __name__ == '__main__':
    main_inst = matuc_impl.main(TextFormatter())
    main_inst.run(sys.argv)
Exemplo n.º 3
0
            error['message'] = {'verbatim': message}
        error = {'error': error}
        sys.stderr.write(''.join(flatten(self.format_recursive(error, 0))) + '\n')

    def emit_usage(self, usage, error=None):
        if error:
            if not error.lower().startswith('error'):
                error = 'Error: ' + error
            print(error.rstrip(), end='\n\n')
        print(usage)

    def clear(self):
        """Clear the screen. There is no easy cross-platform way, so try to use
        cls/clear."""
        if sys.platform.startswith('win'):
            os.system('cmd /c cls')
        elif shutil.which('clear'):
            os.system('clear')
        else:
            print("\n" + "-" * matuc_impl.getTerminalSize()[0])
            if 'linux' in sys.platform:
                self.register_warning({'message': ("The `clear` command was not"
                    " found, install it, i.e. with `apt-get install ncurses-bin`.")})




if __name__ == '__main__':
    main_inst = matuc_impl.main(TextFormatter())
    main_inst.run(sys.argv)
    def emit_result(self, result):
        warnings = self.get_warnings()
        output = {}
        if warnings:
            output['warnings'] = warnings
        output['result'] = result
        self.__emit_json(output)

    def emit_error(self, error):
        warnings = self.get_warnings()
        output = {'error': error}
        if warnings:
            output['warnings'] = warnings
        self.__emit_json(output)

    def emit_usage(self, usage, error=None):
        output = {'usage': usage}
        if error:
            output['error'] = error.rstrip()
        self.__emit_json(output)

    def clear(self):
        """Screen will _not_ be cleared in JSON output  mode."""
        pass

if __name__ == '__main__':
    main_inst = matuc_impl.main(JsonFormatter())
    main_inst.run(sys.argv)