Skip to content

Commit

Permalink
Merge pull request #475 from hercules-ci/hci-state-get-version
Browse files Browse the repository at this point in the history
hci state get: Add --version INT
  • Loading branch information
roberth authored Dec 2, 2022
2 parents 6820b7c + 4c0a7c1 commit 18b11f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions hercules-ci-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- `hci state get --version INT` added, to retrieve a specific revision of a remote state file.

## 0.3.3 - 2022-11-15

### Added
Expand Down
8 changes: 6 additions & 2 deletions hercules-ci-cli/src/Hercules/CLI/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Hercules.CLI.Client
import Hercules.CLI.Common (runAuthenticated)
import Hercules.CLI.Options (mkCommand, subparser)
import Hercules.CLI.Project (ProjectPath (projectPathOwner, projectPathProject, projectPathSite), findProjectContextually, projectOption)
import Options.Applicative (bashCompleter, completer, help, long, metavar, strOption)
import Options.Applicative (auto, bashCompleter, completer, help, long, metavar, option, strOption)
import qualified Options.Applicative as Optparse
import Protolude hiding (option)
import RIO (RIO, runRIO, withBinaryFile)
Expand All @@ -37,11 +37,12 @@ getCommandParser = do
projectMaybe <- optional projectOption
name <- nameOption
file <- fileOption
versionMaybe <- optional versionOption
pure do
runAuthenticated do
projectStateClient <- getProjectAndClient projectMaybe
-- TODO: version
runHerculesClientStream (getStateData projectStateClient name Nothing) \case
runHerculesClientStream (getStateData projectStateClient name versionMaybe) \case
Left e -> dieWithHttpError e
Right (Headers r _) -> do
runConduitRes $
Expand Down Expand Up @@ -73,6 +74,9 @@ nameOption = strOption $ long "name" <> metavar "NAME" <> help "Name of the stat
fileOption :: Optparse.Parser FilePath
fileOption = strOption $ long "file" <> metavar "FILE" <> help "Local path of the state file or - for stdio" <> completer (bashCompleter "file")

versionOption :: Optparse.Parser Int
versionOption = option auto $ long "version" <> metavar "INT" <> help "Version of the state file to retrieve"

getProjectAndClient :: (Has HerculesClientToken r, Has HerculesClientEnv r) => Maybe ProjectPath -> RIO r (ProjectStateResourceGroup ClientAuth (AsClientT ClientM))
getProjectAndClient projectMaybe =
case projectMaybe of
Expand Down

0 comments on commit 18b11f4

Please sign in to comment.