From cce425e61940cb978366126cfcbeb1f4924c5494 Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Mon, 13 May 2024 00:58:42 +0500 Subject: [PATCH] chore: rename option --dump-schema to --dump-schema-cache --- CHANGELOG.md | 1 + docs/references/cli.rst | 2 +- nix/tools/tests.nix | 4 ++-- src/PostgREST/CLI.hs | 12 ++++++------ test/io/fixtures.yaml | 2 +- test/io/test_cli.py | 4 +++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6192d36d53..d8ef2bc4ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/references/cli.rst b/docs/references/cli.rst index ccc85afdac..ee254e9b80 100644 --- a/docs/references/cli.rst +++ b/docs/references/cli.rst @@ -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. diff --git a/nix/tools/tests.nix b/nix/tools/tests.nix index f842b7948c..72689dea24 100644 --- a/nix/tools/tests.nix +++ b/nix/tools/tests.nix @@ -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; @@ -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 = diff --git a/src/PostgREST/CLI.hs b/src/PostgREST/CLI.hs index 4d6e8d67a1..374d7c2ea4 100644 --- a/src/PostgREST/CLI.hs +++ b/src/PostgREST/CLI.hs @@ -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 @@ -70,7 +70,7 @@ data CLI = CLI data Command = CmdRun | CmdDumpConfig - | CmdDumpSchema + | CmdDumpSchemaCache data Example = ExampleFile | ExampleDb | ExampleEnv @@ -115,7 +115,7 @@ readCLIShowHelp = cliParser :: O.Parser CLI cliParser = CLI - <$> (dumpConfigFlag <|> dumpSchemaFlag) + <$> (dumpConfigFlag <|> dumpSchemaCacheFlag) <*> O.optional configFileOption configFileOption = @@ -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] diff --git a/test/io/fixtures.yaml b/test/io/fixtures.yaml index 75aff7f45f..0fd83e46ac 100644 --- a/test/io/fixtures.yaml +++ b/test/io/fixtures.yaml @@ -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 diff --git a/test/io/test_cli.py b/test/io/test_cli.py index a85a0111c2..f00828201d 100644 --- a/test/io/test_cli.py +++ b/test/io/test_cli.py @@ -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",