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 May 12, 2024
1 parent 2529098 commit cce425e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #3248, Add more config examples to CLI - @taimoorzaeem
+ Now accepts ``--example-file``, ``--example-db``, and ``--example-env``
+ Replace ``-e`` and ``--example`` with ``--example-file``
+ Rename option ``--dump-schema`` to ``--dump-schema-cache``

### Fixed

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

.. code:: bash
$ postgrest [--dump-schema] [FILENAME]
$ postgrest [--dump-schema-cache] [FILENAME]
Here ``FILENAME`` is the path to configuration file.
4 changes: 2 additions & 2 deletions nix/tools/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ let
dumpSchema =
checkedShellScript
{
name = "postgrest-dump-schema";
name = "postgrest-dump-schema-cache";
docs = "Dump the loaded schema's SchemaCache in JSON format.";
workingDir = "/";
withEnv = postgrest.env;
Expand All @@ -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 @@ -70,7 +70,7 @@ data CLI = CLI
data Command
= CmdRun
| CmdDumpConfig
| CmdDumpSchema
| CmdDumpSchemaCache

data Example = ExampleFile | ExampleDb | ExampleEnv

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

configFileOption =
Expand All @@ -128,9 +128,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 cce425e

Please sign in to comment.