diff --git a/CHANGELOG.md b/CHANGELOG.md index eb62cfe4b..3f7f97a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Add linux/arm64 platform support to the official Docker image * Add `cat` command for downloading file contents directly to stdout +* Add `-r` as an alias for `--recursive` argument +* Add `-q` as an alias for `--quiet` argument ### Fixed * Emit `Using https://api.backblazeb2.com` message to stderr instead of stdout, therefor prevent JSON output corruption diff --git a/b2/console_tool.py b/b2/console_tool.py index 5c93bc9cc..7774ad053 100644 --- a/b2/console_tool.py +++ b/b2/console_tool.py @@ -662,7 +662,7 @@ def get_parser(cls, subparsers=None, parents=None, for_docs=False): common_parser.add_argument('--logConfig', help=argparse.SUPPRESS) common_parser.add_argument('--profile', default=None, help=argparse.SUPPRESS) common_parser.add_argument( - '--quiet', action='store_true', default=False, help=argparse.SUPPRESS + '-q', '--quiet', action='store_true', default=False, help=argparse.SUPPRESS ) parents = [common_parser] @@ -1981,7 +1981,7 @@ class AbstractLsCommand(Command, metaclass=ABCMeta): @classmethod def _setup_parser(cls, parser): parser.add_argument('--versions', action='store_true') - parser.add_argument('--recursive', action='store_true') + parser.add_argument('-r', '--recursive', action='store_true') parser.add_argument('--withWildcard', action='store_true') parser.add_argument('bucketName').completer = bucket_name_completer parser.add_argument('folderName', nargs='?').completer = file_name_completer diff --git a/test/unit/console_tool/test_download_file.py b/test/unit/console_tool/test_download_file.py index 717b05648..326ddc9fd 100644 --- a/test/unit/console_tool/test_download_file.py +++ b/test/unit/console_tool/test_download_file.py @@ -54,13 +54,19 @@ def uploaded_file(b2_cli, bucket, local_file): } -def test_download_file_by_name(b2_cli, local_file, uploaded_file, tmp_path): +@pytest.mark.parametrize( + 'flag,expected_stdout', [ + ('--noProgress', EXPECTED_STDOUT_DOWNLOAD), + ('-q', ''), + ('--quiet', ''), + ] +) +def test_download_file_by_name(b2_cli, local_file, uploaded_file, tmp_path, flag, expected_stdout): output_path = tmp_path / 'output.txt' b2_cli.run( [ - 'download-file-by-name', '--noProgress', uploaded_file['bucket'], - uploaded_file['fileName'], + 'download-file-by-name', uploaded_file['bucket'], uploaded_file['fileName'], str(output_path) ], expected_stdout=EXPECTED_STDOUT_DOWNLOAD @@ -68,37 +74,22 @@ def test_download_file_by_name(b2_cli, local_file, uploaded_file, tmp_path): assert output_path.read_text() == uploaded_file['content'] -def test_download_file_by_name_quietly(b2_cli, uploaded_file, tmp_path): - output_path = tmp_path / 'output.txt' - - b2_cli.run( - [ - 'download-file-by-name', '--quiet', uploaded_file['bucket'], uploaded_file['fileName'], - str(output_path) - ], - expected_stdout='' - ) - assert output_path.read_text() == uploaded_file['content'] - - -def test_download_file_by_id(b2_cli, uploaded_file, tmp_path): +@pytest.mark.parametrize( + 'flag,expected_stdout', [ + ('--noProgress', EXPECTED_STDOUT_DOWNLOAD), + ('-q', ''), + ('--quiet', ''), + ] +) +def test_download_file_by_id(b2_cli, uploaded_file, tmp_path, flag, expected_stdout): output_path = tmp_path / 'output.txt' b2_cli.run( - ['download-file-by-id', '--noProgress', '9999', - str(output_path)], - expected_stdout=EXPECTED_STDOUT_DOWNLOAD + ['download-file-by-id', flag, '9999', str(output_path)], expected_stdout=expected_stdout ) assert output_path.read_text() == uploaded_file['content'] -def test_download_file_by_id_quietly(b2_cli, uploaded_file, tmp_path): - output_path = tmp_path / 'output.txt' - - b2_cli.run(['download-file-by-id', '--quiet', '9999', str(output_path)], expected_stdout='') - assert output_path.read_text() == uploaded_file['content'] - - @skip_on_windows(reason='os.mkfifo is not supported on Windows') def test_download_file_by_name__named_pipe( b2_cli, local_file, uploaded_file, tmp_path, bg_executor diff --git a/test/unit/test_console_tool.py b/test/unit/test_console_tool.py index 285ba3312..649d7b56b 100644 --- a/test/unit/test_console_tool.py +++ b/test/unit/test_console_tool.py @@ -2173,6 +2173,7 @@ def test_ls(self): c ''' self._run_command(['ls', '--recursive', 'my-bucket'], expected_stdout, '', 0) + self._run_command(['ls', '-r', 'my-bucket'], expected_stdout, '', 0) # Check long output. (The format expects full-length file ids, so it causes whitespace here) expected_stdout = '''