Skip to content

Commit

Permalink
chore: rename option --dump-schema to --dump-schema-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoorzaeem committed Jun 9, 2024
1 parent 1563ffd commit 1383371
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- #3248, Modified some CLI options - @taimoorzaeem
+ Replace ``-e`` and ``--example`` with ``--example-file``
+ Rename option ``--dump-schema`` to ``--dump-schema-cache``

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion docs/references/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ Dump Schema

.. code:: bash
$ postgrest [--dump-schema]
$ postgrest [--dump-schema-cache]
Dumps the schema cache in JSON format.
2 changes: 1 addition & 1 deletion nix/tools/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let
''
${withTools.withPg} -f test/spec/fixtures/load.sql \
${cabal-install}/bin/cabal v2-run ${devCabalOptions} --verbose=0 -- \
postgrest --dump-schema
postgrest --dump-schema-cache
'';

coverage =
Expand Down
12 changes: 6 additions & 6 deletions src/PostgREST/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ main CLI{cliCommand, cliPath} = do
CmdDumpConfig -> do
when configDbConfig $ AppState.reReadConfig True appState
putStr . Config.toText =<< AppState.getConfig appState
CmdDumpSchema -> putStrLn =<< dumpSchema appState
CmdDumpSchemaCache -> putStrLn =<< dumpSchema appState
CmdRun -> App.run appState)

-- | Dump SchemaCache schema to JSON
Expand All @@ -71,7 +71,7 @@ data CLI = CLI
data Command
= CmdRun
| CmdDumpConfig
| CmdDumpSchema
| CmdDumpSchemaCache

data Example = ExampleFile | ExampleDb | ExampleEnv

Expand Down Expand Up @@ -116,7 +116,7 @@ readCLIShowHelp =
cliParser :: O.Parser CLI
cliParser =
CLI
<$> (dumpConfigFlag <|> dumpSchemaFlag)
<$> (dumpConfigFlag <|> dumpSchemaCacheFlag)
<*> O.optional configFileOption

configFileOption =
Expand All @@ -129,9 +129,9 @@ readCLIShowHelp =
O.long "dump-config"
<> O.help "Dump loaded configuration and exit"

dumpSchemaFlag =
O.flag CmdRun CmdDumpSchema $
O.long "dump-schema"
dumpSchemaCacheFlag =
O.flag CmdRun CmdDumpSchemaCache $
O.long "dump-schema-cache"
<> O.help "Dump loaded schema as JSON and exit (for debugging, output structure is unstable)"

exampleConfig :: Example -> [Char]
Expand Down
2 changes: 1 addition & 1 deletion test/io/fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cli:
- name: dump config
args: ['--dump-config']
- name: dump schema
args: ['--dump-schema']
args: ['--dump-schema-cache']
use_defaultenv: true
- name: no config
# failures: config files
Expand Down
4 changes: 3 additions & 1 deletion test/io/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv):
def test_schema_cache_snapshot(baseenv, key, snapshot_yaml):
"Dump of schema cache should match snapshot."

schema_cache = yaml.load(cli(["--dump-schema"], env=baseenv), Loader=yaml.Loader)
schema_cache = yaml.load(
cli(["--dump-schema-cache"], env=baseenv), Loader=yaml.Loader
)
formatted = yaml.dump(
schema_cache[key],
encoding="utf8",
Expand Down

0 comments on commit 1383371

Please sign in to comment.