Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added file subcommands #1024

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
36d05ff
added file info, url, cat, upload
adal-chiriliuc-reef Apr 24, 2024
adbb53f
add subcommand to replaced_by_cmd
adal-chiriliuc-reef Apr 25, 2024
e35d1b9
use file subcommands
adal-chiriliuc-reef Apr 25, 2024
09769e6
use file upload subcommand
adal-chiriliuc-reef Apr 25, 2024
bc60f7a
deduplicated and moved _setup_parser method into parent DownloadFileB…
adal-chiriliuc-reef Apr 25, 2024
e7ff9f6
use file download subcommand
adal-chiriliuc-reef Apr 25, 2024
66685c2
add file copy-by-id subcommand
adal-chiriliuc-reef Apr 25, 2024
2d31d7e
use file copy-by-id subcommand
adal-chiriliuc-reef Apr 25, 2024
b0e9f79
file hide subcommand
adal-chiriliuc-reef Apr 25, 2024
8a076fc
fixed typo
adal-chiriliuc-reef Apr 25, 2024
315f77d
fixed typo
adal-chiriliuc-reef Apr 25, 2024
7c94990
added file update subcommand
adal-chiriliuc-reef Apr 25, 2024
df03861
updated tests
adal-chiriliuc-reef Apr 25, 2024
91b5724
updated doc string
adal-chiriliuc-reef Apr 25, 2024
b10f3fb
updated file update doc string
adal-chiriliuc-reef Apr 26, 2024
2895c67
deprecated commands unit tests
adal-chiriliuc-reef Apr 26, 2024
68be0b8
updated doc string
adal-chiriliuc-reef Apr 26, 2024
f54dbd2
fixed hyphen in command name
adal-chiriliuc-reef Apr 26, 2024
3fd6eed
sort command help lines
adal-chiriliuc-reef Apr 26, 2024
b17e93c
workaround to hide command aliases in usage
adal-chiriliuc-reef Apr 26, 2024
aaefec9
deprecated download-url-with-auth and replaced with file url
adal-chiriliuc-reef Apr 29, 2024
e294c7a
deprecate delete-file-version
adal-chiriliuc-reef Apr 29, 2024
86d6748
added file large subcommand
adal-chiriliuc-reef Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ cat source_file.txt | docker run -i --rm -v b2:/root backblazeit/b2:latest b2v3
or by mounting local files in the docker container:

```bash
docker run --rm -v b2:/root -v /home/user/path/to/data:/data backblazeit/b2:latest b2v3 upload-file bucket_name /data/source_file.txt target_file_name
docker run --rm -v b2:/root -v /home/user/path/to/data:/data backblazeit/b2:latest b2v3 file upload bucket_name /data/source_file.txt target_file_name
```

## ApiVer CLI versions (`b2` vs `b2v3`, `b2v4`, etc.)
Expand Down
3 changes: 2 additions & 1 deletion b2/_internal/_b2v4/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
B2.register_subcommand(Cat)
B2.register_subcommand(GetAccountInfo)
B2.register_subcommand(GetBucket)
B2.register_subcommand(FileInfo)
B2.register_subcommand(FileInfo2)
B2.register_subcommand(GetFileInfo)
B2.register_subcommand(GetDownloadAuth)
B2.register_subcommand(GetDownloadUrlWithAuth)
Expand Down Expand Up @@ -60,3 +60,4 @@
B2.register_subcommand(Replication)
B2.register_subcommand(Account)
B2.register_subcommand(BucketCmd)
B2.register_subcommand(File)
25 changes: 25 additions & 0 deletions b2/_internal/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,31 @@ def print_help(self, *args, show_all: bool = False, **kwargs):
):
super().print_help(*args, **kwargs)

def format_usage(self):
# TODO We don't want to list underscore aliases subcommands in the usage.
# Unfortunately the only way found was to temporarily remove the aliases,
# print the usage and then restore the aliases since the formatting is deep
# inside the Python argparse module.
# We restore the original dictionary which we don't modify, just in case
# someone else has taken a reference to it.
subparsers_action = None
original_choices = None
if self._subparsers is not None:
for action in self._subparsers._actions:
if isinstance(action, argparse._SubParsersAction):
subparsers_action = action
original_choices = action.choices
action.choices = {
key: choice
for key, choice in action.choices.items() if "_" not in key
}
# only one subparser supported
break
usage = super().format_usage()
if subparsers_action is not None:
subparsers_action.choices = original_choices
return usage


SUPPORT_CAMEL_CASE_ARGUMENTS = False

Expand Down
1 change: 1 addition & 0 deletions b2/_internal/b2v3/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ class Ls(B2URIBucketNFolderNameArgMixin, BaseLs):
B2.register_subcommand(Replication)
B2.register_subcommand(Account)
B2.register_subcommand(BucketCmd)
B2.register_subcommand(File)
1 change: 1 addition & 0 deletions b2/_internal/b2v3/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ class Rm(B2URIBucketNFolderNameArgMixin, BaseRm):

- **listFiles**
- **deleteFiles**
- **bypassGovernance** (if --bypass-governance is used)
"""
Loading
Loading