Skip to content

Commit

Permalink
re-introduce deprecated options support with the config command
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Jan 8, 2024
1 parent cd5cf3b commit e9a937b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Config.idr
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ propSetter RequestUsers = update parseBool (\b => { requestUsers := b })
propSetter CommentOnRequest = update parseBool (\b => { commentOnRequest := b })
propSetter DefaultRemote = update Just (\s => { defaultRemote := s })
propSetter GithubPAT = update Just (\s => { githubPAT := Just $ hide s })
propSetter AssignTeams = update parseBool (\b => { requestTeams := b })
propSetter AssignUsers = update parseBool (\b => { requestUsers := b })
propSetter CommentOnAssign = update parseBool (\b => { commentOnRequest := b })

||| Attempt to set a property and value given String representations.
||| After setting, write the config and return the updated result.
Expand All @@ -152,6 +155,9 @@ propGetter RequestUsers = show . requestUsers
propGetter CommentOnRequest = show . commentOnRequest
propGetter DefaultRemote = show . defaultRemote
propGetter GithubPAT = maybe "Not set (will use $GITHUB_PAT environment variable)" show . githubPAT
propGetter AssignTeams = show . requestTeams
propGetter AssignUsers = show . requestUsers
propGetter CommentOnAssign = show . commentOnRequest

export
getConfig : Config =>
Expand Down
23 changes: 23 additions & 0 deletions src/Data/Config.idr
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ data SettableProp : (name : String) -> (help : String) -> Type where
"githubPAT"
"[string] The Personal Access Token Harmony should use to authenticate with GitHub. You can leave this unset if you want to set a PAT via the GITHUB_PAT environment variable."

-- TODO 4.0.0: remove deprecated aliases below
AssignTeams : SettableProp
"assignTeams"
"[true/false] Deprecated alias for the 'requestTeams' config option."
AssignUsers : SettableProp
"assignUsers"
"[true/false] Deprecated alias for the 'requestUsers' config option."
CommentOnAssign : SettableProp
"commentOnAssign"
"[true/false] Deprecated alias for the 'commentOnRequest' config option."

public export
SomeSettableProp : Type
SomeSettableProp = (n ** h ** SettableProp n h)
Expand All @@ -121,6 +132,9 @@ settablePropNamed "commentOnRequest" = Just $ Evidence _ CommentOnRequest
settablePropNamed "defaultRemote" = Just $ Evidence _ DefaultRemote
settablePropNamed "githubPAT" = Just $ Evidence _ GithubPAT
settablePropNamed "requestUsers" = Just $ Evidence _ RequestUsers
settablePropNamed "assignTeams" = Just $ Evidence _ AssignTeams
settablePropNamed "assignUsers" = Just $ Evidence _ AssignUsers
settablePropNamed "commentOnAssign" = Just $ Evidence _ CommentOnAssign
settablePropNamed _ = Nothing

namespace SettablePropNamedProps
Expand All @@ -130,6 +144,9 @@ namespace SettablePropNamedProps
settablePropNamedOnto {p = CommentOnRequest} = Refl
settablePropNamedOnto {p = DefaultRemote} = Refl
settablePropNamedOnto {p = GithubPAT} = Refl
settablePropNamedOnto {p = AssignTeams} = Refl
settablePropNamedOnto {p = AssignUsers} = Refl
settablePropNamedOnto {p = CommentOnAssign} = Refl

settableProps : List SomeSettableProp
settableProps = [
Expand All @@ -138,6 +155,9 @@ settableProps = [
, (_ ** _ ** CommentOnRequest)
, (_ ** _ ** DefaultRemote)
, (_ ** _ ** GithubPAT)
, (_ ** _ ** AssignUsers)
, (_ ** _ ** AssignTeams)
, (_ ** _ ** CommentOnAssign)
]

namespace SettablePropsProps
Expand All @@ -147,6 +167,9 @@ namespace SettablePropsProps
settablePropsCovering {p = CommentOnRequest} = %search
settablePropsCovering {p = DefaultRemote} = %search
settablePropsCovering {p = GithubPAT} = %search
settablePropsCovering {p = AssignTeams} = %search
settablePropsCovering {p = AssignUsers} = %search
settablePropsCovering {p = CommentOnAssign} = %search

propName' : SomeSettableProp -> String
propName' (_ ** _ ** p) = propName p
Expand Down
2 changes: 1 addition & 1 deletion src/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ handleConfiguredArgs : Config => Git =>
-> Promise ()
handleConfiguredArgs _ ["config"] =
reject $ "The config command expects one or two arguments. "
++ "Specify a property to read out or a property and a value to set it to."
++ "Specify a property to read it out or specify both a property and a value to set it to."
++ "\n\n"
++ settablePropsWithHelp
handleConfiguredArgs _ ["config", prop] =
Expand Down

0 comments on commit e9a937b

Please sign in to comment.