Reorder arg list, note that schema is not required

This commit is contained in:
Joe Nelson
2016-02-05 09:27:24 -08:00
parent 56426b896a
commit ccb3eba9e3
2 changed files with 6 additions and 7 deletions
+3 -3
View File
@@ -65,7 +65,7 @@ If you want to run the test suite, stack can do that too: `stack test`.
### Running the Server ### Running the Server
```bash ```bash
postgrest postgres://user:pass@host:port/db -s public -a anon_user [other flags] postgrest postgres://user:pass@host:port/db -a anon_user [other flags]
``` ```
The user in the connection string is the "authenticator role," i.e. The user in the connection string is the "authenticator role," i.e.
@@ -73,7 +73,7 @@ a role which is used temporarily to switch into other roles depending
on the authentication request JWT. For simple API's you can use the on the authentication request JWT. For simple API's you can use the
same role for authenticator and anonymous. same role for authenticator and anonymous.
The possible flags are: The complete list of options:
<dl> <dl>
<dt>-p, --port</dt> <dt>-p, --port</dt>
@@ -84,7 +84,7 @@ The possible flags are:
<dd>The database role used to execute commands for those requests <dd>The database role used to execute commands for those requests
which provide no JWT authorization.</dd> which provide no JWT authorization.</dd>
<dt>-s, --schema (required)</dt> <dt>-s, --schema</dt>
<dd>The db schema which you want to expose as an API. For historical <dd>The db schema which you want to expose as an API. For historical
reasons it defaults to <code>1</code>, but you're more likely reasons it defaults to <code>1</code>, but you're more likely
to want to choose a value of <code>public</code>.</dd> to want to choose a value of <code>public</code>.</dd>
+3 -4
View File
@@ -37,9 +37,9 @@ import Prelude
-- | Data type to store all command line options -- | Data type to store all command line options
data AppConfig = AppConfig { data AppConfig = AppConfig {
configDatabase :: String configDatabase :: String
, configPort :: Int
, configAnonRole :: String , configAnonRole :: String
, configSchema :: String , configSchema :: String
, configPort :: Int
, configJwtSecret :: Secret , configJwtSecret :: Secret
, configPool :: Int , configPool :: Int
, configMaxRows :: Maybe Integer , configMaxRows :: Maybe Integer
@@ -48,10 +48,9 @@ data AppConfig = AppConfig {
argParser :: Parser AppConfig argParser :: Parser AppConfig
argParser = AppConfig argParser = AppConfig
<$> argument str (help "(REQUIRED) database connection string" <> metavar "DB_URL") <$> argument str (help "(REQUIRED) database connection string" <> metavar "DB_URL")
<*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault)
<*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE") <*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE")
<*> strOption (long "schema" <> short 's' <> help "(REQUIRED) schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) <*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault)
<*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault)
<*> (secret . cs <$> <*> (secret . cs <$>
strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault)) strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault))
<*> option auto (long "pool" <> short 'o' <> help "max connections in database pool" <> metavar "COUNT" <> value 10 <> showDefault) <*> option auto (long "pool" <> short 'o' <> help "max connections in database pool" <> metavar "COUNT" <> value 10 <> showDefault)