How to use tldr - 10 common examples

To help you get started, we’ve selected a few tldr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lord63 / tldr.py / tests / test_config.py View on Github external
def _assert_exception_message(self, expected_message):
        with self.assertRaises(SystemExit) as error:
            get_config()
        assert error.exception.args[0] == expected_message
github lord63 / tldr.py / tests / test_parse.py View on Github external
},
            'platform': 'linux',
            'repo_directory': '/tmp/tldr'
        }
        expected_result = (
            '\n'
            '\x1b[0m\x1b[34m  Main node command\n'
            '\x1b[0m\n\x1b[0m\x1b[32m- Call an interactive node shell'
            '\n\x1b[0m\n\x1b[0m\x1b[36m  node\n'
            '\x1b[0m\n\x1b[0m\x1b[32m- Execute node on a JS file\n'
            '\x1b[0m\n\x1b[0m\x1b[36m  node {{FILENAME}}.js\n'
            '\x1b[0m\n\x1b[0m'
        )
        with mock.patch('tldr.parser.get_config', return_value=mock_config):
            with mock.patch('io.open', mock.mock_open(read_data=page_content)):
                result = parse_page('/repo_directory/pages/common/node.md')
                assert ''.join(result) == expected_result
github lord63 / tldr.py / tests / basic.py View on Github external
def call_init_command(self, repo_dir=path.join(ROOT, 'mock_tldr'),
                          platform='linux'):
        with mock.patch('click.prompt', side_effect=[repo_dir, platform]):
            result = self.runner.invoke(cli.init)
        return result
github lord63 / tldr.py / tests / basic.py View on Github external
def call_reindex_command(self):
        result = self.runner.invoke(cli.reindex)
        return result
github lord63 / tldr.py / tests / basic.py View on Github external
def call_find_command(self, command_name, platform):
        command_args = (
            [command_name, '--on', platform] if platform else [command_name])
        result = self.runner.invoke(cli.find, command_args)
        return result
github lord63 / tldr.py / tests / basic.py View on Github external
def call_locate_command(self, command_name, platform):
        command_args = (
            [command_name, '--on', platform] if platform else [command_name])
        result = self.runner.invoke(cli.locate, command_args)
        return result
github lord63 / tldr.py / tests / basic.py View on Github external
def call_update_command(self):
        with mock.patch('tldr.cli.build_index', return_value=None):
            result = self.runner.invoke(cli.update)
        return result
github lord63 / tldr.py / tldr / cli.py View on Github external
def find_page_location(command, specified_platform):
    """Find the command man page in the pages directory."""
    repo_directory = get_config()['repo_directory']
    default_platform = get_config()['platform']
    command_platform = (
        specified_platform if specified_platform else default_platform)

    with io.open(path.join(repo_directory, 'pages/index.json'),
                 encoding='utf-8') as f:
        index = json.load(f)
    command_list = [item['name'] for item in index['commands']]
    if command not in command_list:
        sys.exit(
            ("Sorry, we don't support command: {0} right now.\n"
             "You can file an issue or send a PR on github:\n"
             "    https://github.com/tldr-pages/tldr").format(command))

    supported_platforms = index['commands'][
        command_list.index(command)]['platform']
    if command_platform in supported_platforms:
github lord63 / tldr.py / tldr / cli.py View on Github external
def find_page_location(command, specified_platform):
    """Find the command man page in the pages directory."""
    repo_directory = get_config()['repo_directory']
    default_platform = get_config()['platform']
    command_platform = (
        specified_platform if specified_platform else default_platform)

    with io.open(path.join(repo_directory, 'pages/index.json'),
                 encoding='utf-8') as f:
        index = json.load(f)
    command_list = [item['name'] for item in index['commands']]
    if command not in command_list:
        sys.exit(
            ("Sorry, we don't support command: {0} right now.\n"
             "You can file an issue or send a PR on github:\n"
             "    https://github.com/tldr-pages/tldr").format(command))

    supported_platforms = index['commands'][
        command_list.index(command)]['platform']
github lord63 / tldr.py / tldr / cli.py View on Github external
def build_index():
    repo_directory = get_config()['repo_directory']
    index_path = path.join(repo_directory, 'pages', 'index.json')
    page_path = path.join(repo_directory, 'pages')

    tree_generator = os.walk(page_path)
    folders = next(tree_generator)[1]
    commands, new_index = {}, {}
    for folder in folders:
        pages = next(tree_generator)[2]
        for page in pages:
            command_name = path.splitext(page)[0]
            if command_name not in commands:
                commands[command_name] = {'name': command_name,
                                          'platform': [folder]}
            else:
                commands[command_name]['platform'].append(folder)
    command_list = [item[1] for item in

tldr

command line client for tldr

MIT
Latest version published 6 months ago

Package Health Score

74 / 100
Full package analysis