Skip to content

Commit 239b071

Browse files
committed
Fixed cli and init command
1 parent 44c77e0 commit 239b071

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

gql/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,20 @@ def cli():
3636

3737
@cli.command()
3838
@click.option('--schema', prompt=SCHEMA_PROMPT, default='http://localhost:4000')
39+
@click.option('--endpoint', prompt=SCHEMA_PROMPT, default='same as schema')
3940
@click.option('--root', prompt=ROOT_PROMPT, default='./src')
40-
@click.option('-c', '--config', 'config_filename', default=DEFAULT_CONFIG_FNAME, type=click.Path(exists=True))
41-
def init(schema, root, config_filename):
41+
@click.option('-c', '--config', 'config_filename', default=DEFAULT_CONFIG_FNAME, type=click.Path(exists=False))
42+
def init(schema, endpoint, root, config_filename):
4243
if isfile(config_filename):
4344
click.confirm(f'{config_filename} already exists. Are you sure you want to continue?', abort=True)
4445

46+
if endpoint == 'same as schema':
47+
endpoint = schema
48+
4549
documents = join_paths(root, '**/*.graphql')
4650
config = Config(
4751
schema=schema,
48-
endpoint=schema,
52+
endpoint=endpoint,
4953
documents=documents
5054
)
5155

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pytest-mock = "^1.10"
3636
deepdiff = "^3.3"
3737

3838
[tool.poetry.scripts]
39-
my-script = 'gql:cli'
39+
gql = 'gql.cli:cli'
4040

4141
[build-system]
4242
requires = ["poetry>=0.12"]

0 commit comments

Comments
 (0)