Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion man/stackctl.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ stackctl(1) - manage CloudFormation Stacks through specifications
## OPTIONS

* `-d`, `--directory`=<PATH>:
Where to find specifications. Default is `.`.
Use the stack collection located at <PATH> (default: current working
directory).

* `--filter`=<PATTERN[,PATTERN]>:
Restrict specifications to those whose paths match any given <PATTERN>.
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ library:
- monad-logger
- mtl
- optparse-applicative
- prettyprinter
- resourcet
- rio
- semigroups
Expand Down
8 changes: 6 additions & 2 deletions src/Stackctl/DirectoryOption.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ instance HasDirectoryOption DirectoryOption where
envDirectoryOption :: Env.Parser Env.Error DirectoryOption
envDirectoryOption =
Env.var (Env.str <=< Env.nonempty) "DIRECTORY"
$ Env.help "Operate on specifications in this directory"
$ Env.help directoryHelp

directoryOption :: Parser DirectoryOption
directoryOption =
Expand All @@ -39,6 +39,10 @@ directoryOption =
[ short 'd'
, long "directory"
, metavar "PATH"
, help "Operate on specifications in PATH"
, help directoryHelp
, action "directory"
]

directoryHelp :: String
directoryHelp =
"Use the stack collection located at PATH (default: current working directory)"
19 changes: 17 additions & 2 deletions src/Stackctl/Subcommand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Stackctl.Prelude

import qualified Env
import Options.Applicative
import Prettyprinter (pretty, vsep)
import Prettyprinter.Util (reflow)
import Stackctl.AWS (handlingServiceError)
import Stackctl.AutoSSO
import Stackctl.CLI
Expand Down Expand Up @@ -46,7 +48,9 @@ runSubcommand' title parseEnv parseCLI sp = do
(options, act) <-
applyEnv
<$> Env.parse (Env.header $ unpack title) parseEnv
<*> execParser (withInfo title $ (,) <$> parseCLI <*> subparser sp)
<*> customExecParser
(prefs helpShowGlobals)
(withInfo title $ (,) <$> parseCLI <*> subparser sp)

act options
where
Expand Down Expand Up @@ -78,4 +82,15 @@ runAppSubcommand f subOptions options =
$ f subOptions

withInfo :: Text -> Parser a -> ParserInfo a
withInfo d p = info (p <**> helper) $ progDesc (unpack d) <> fullDesc
withInfo d p =
info (p <**> helper)
$ progDescDoc
$ Just
$ vsep
[ pretty d
, ""
, reflow
$ "By default, this will operate on the entire stack collection. To"
<> " operate on a specific stack or set of stacks, use the --filter"
<> " argument to filter the collection by file path."
]
3 changes: 2 additions & 1 deletion stackctl.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.18

-- This file has been generated from package.yaml by hpack version 0.37.0.
-- This file has been generated from package.yaml by hpack version 0.38.1.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -128,6 +128,7 @@ library
, monad-logger
, mtl
, optparse-applicative
, prettyprinter
, resourcet
, rio
, semigroups
Expand Down