mirror of
https://github.com/simonw/dclient.git
synced 2026-07-23 01:14:32 +02:00
Example usage in --help, closes #22
This commit is contained in:
parent
f0058258b2
commit
081aeb32a2
4 changed files with 81 additions and 5 deletions
|
|
@ -27,6 +27,13 @@ def query(url_or_alias, sql, token):
|
|||
Run a SQL query against a Datasette database URL
|
||||
|
||||
Returns a JSON array of objects
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient query \\
|
||||
https://datasette.io/content \\
|
||||
'select * from news limit 10'
|
||||
"""
|
||||
aliases_file = get_config_dir() / "aliases.json"
|
||||
aliases = _load_aliases(aliases_file)
|
||||
|
|
@ -247,7 +254,14 @@ def alias():
|
|||
@alias.command(name="list")
|
||||
@click.option("_json", "--json", is_flag=True, help="Output raw JSON")
|
||||
def list_(_json):
|
||||
"List aliases"
|
||||
"""
|
||||
List aliases
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient aliases list
|
||||
"""
|
||||
aliases_file = get_config_dir() / "aliases.json"
|
||||
aliases = _load_aliases(aliases_file)
|
||||
if _json:
|
||||
|
|
@ -261,7 +275,18 @@ def list_(_json):
|
|||
@click.argument("name")
|
||||
@click.argument("url")
|
||||
def alias_add(name, url):
|
||||
"Add an alias"
|
||||
"""
|
||||
Add an alias
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient alias add content https://datasette.io/content
|
||||
|
||||
Then:
|
||||
|
||||
dclient query content 'select * from news limit 3'
|
||||
"""
|
||||
config_dir = get_config_dir()
|
||||
config_dir.mkdir(parents=True, exist_ok=True)
|
||||
aliases_file = config_dir / "aliases.json"
|
||||
|
|
@ -273,7 +298,14 @@ def alias_add(name, url):
|
|||
@alias.command(name="remove")
|
||||
@click.argument("name")
|
||||
def alias_remove(name):
|
||||
"Remove an alias"
|
||||
"""
|
||||
Remove an alias
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient alias remove content
|
||||
"""
|
||||
config_dir = get_config_dir()
|
||||
aliases_file = config_dir / "aliases.json"
|
||||
aliases = _load_aliases(aliases_file)
|
||||
|
|
@ -318,7 +350,14 @@ def auth_add(alias_or_url, token):
|
|||
|
||||
@auth.command(name="list")
|
||||
def auth_list():
|
||||
"List stored API tokens"
|
||||
"""
|
||||
List stored API tokens
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient auth list
|
||||
"""
|
||||
auths_file = get_config_dir() / "auth.json"
|
||||
click.echo("Tokens file: {}".format(auths_file))
|
||||
auths = _load_auths(auths_file)
|
||||
|
|
@ -331,7 +370,14 @@ def auth_list():
|
|||
@auth.command(name="remove")
|
||||
@click.argument("alias_or_url")
|
||||
def auth_remove(alias_or_url):
|
||||
"Remove the API token for an alias or URL"
|
||||
"""
|
||||
Remove the API token for an alias or URL
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
dclient auth remove https://datasette.io/content
|
||||
"""
|
||||
config_dir = get_config_dir()
|
||||
auth_file = config_dir / "auth.json"
|
||||
auths = _load_auths(auth_file)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ Usage: dclient alias list [OPTIONS]
|
|||
|
||||
List aliases
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient aliases list
|
||||
|
||||
Options:
|
||||
--json Output raw JSON
|
||||
--help Show this message and exit.
|
||||
|
|
@ -78,6 +82,14 @@ Usage: dclient alias add [OPTIONS] NAME URL
|
|||
|
||||
Add an alias
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient alias add content https://datasette.io/content
|
||||
|
||||
Then:
|
||||
|
||||
dclient query content 'select * from news limit 3'
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
|
|
@ -99,6 +111,10 @@ Usage: dclient alias remove [OPTIONS] NAME
|
|||
|
||||
Remove an alias
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient alias remove content
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ Usage: dclient auth list [OPTIONS]
|
|||
|
||||
List stored API tokens
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient auth list
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
|
|
@ -122,6 +126,10 @@ Usage: dclient auth remove [OPTIONS] ALIAS_OR_URL
|
|||
|
||||
Remove the API token for an alias or URL
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient auth remove https://datasette.io/content
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ Usage: dclient query [OPTIONS] URL_OR_ALIAS SQL
|
|||
|
||||
Returns a JSON array of objects
|
||||
|
||||
Example usage:
|
||||
|
||||
dclient query \
|
||||
https://datasette.io/content \
|
||||
'select * from news limit 10'
|
||||
|
||||
Options:
|
||||
--token TEXT API token
|
||||
--help Show this message and exit.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue