-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add "gas tag" command to list tags
PR Closed: #600
- Loading branch information
1 parent
6e8251d
commit 13ed0cd
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2021 Graviti. Licensed under MIT License. | ||
# | ||
|
||
"""Implementation of gas tag.""" | ||
import sys | ||
from typing import Dict | ||
|
||
import click | ||
|
||
from ..client.gas import DatasetClientType | ||
from .tbrn import TBRN, TBRNType | ||
from .utility import get_dataset_client, get_gas | ||
|
||
|
||
def _implement_tag(obj: Dict[str, str], tbrn: str) -> None: | ||
info = TBRN(tbrn=tbrn) | ||
|
||
if info.type != TBRNType.DATASET: | ||
click.echo(f'To operate a tag, "{info}" must be a dataset', err=True) | ||
sys.exit(1) | ||
|
||
gas = get_gas(**obj) | ||
dataset_client = get_dataset_client(gas, info) | ||
|
||
_list_tags(dataset_client) | ||
|
||
|
||
def _list_tags(dataset_client: DatasetClientType) -> None: | ||
for tag in dataset_client.list_tags(): | ||
click.echo(tag.name) |