@@ -96,7 +96,9 @@ data GReadConfigData
96
96
}
97
97
98
98
instance RenderGitCommand GReadConfigData where
99
- commandArgs (GReadConfigData cScope cName) = [" config" , scopeText, " --get" , cName]
99
+ commandArgs (GReadConfigData cScope cName) =
100
+ filter (not . null )
101
+ [" config" , scopeText, " --get" , cName]
100
102
where
101
103
scopeText :: Text
102
104
scopeText = case cScope of
@@ -112,7 +114,9 @@ data GSetConfigData
112
114
}
113
115
114
116
instance RenderGitCommand GSetConfigData where
115
- commandArgs (GSetConfigData cScope cName cValue) = [" config" , scopeText, cName, " \" " +| cValue|+ " \" " ]
117
+ commandArgs (GSetConfigData cScope cName cValue) =
118
+ filter (not . null )
119
+ [" config" , scopeText, cName, cValue]
116
120
where
117
121
scopeText :: Text
118
122
scopeText = case cScope of
@@ -140,14 +144,22 @@ newtype GAliasesToRemoveData
140
144
141
145
instance RenderGitCommand GAliasesToRemoveData where
142
146
commandArgs (GAliasesToRemoveData cScope) =
143
- [" config" , scopeText, " --name-only" , " --get-regexp" , " \" ^alias.\" " , " \" ^elegant ([-a-z]+)$\" " ]
147
+ [" config" , scopeText, " --name-only" , " --get-regexp" , " ^alias." , " ^elegant ([-a-z]+)$" ]
144
148
where
145
149
scopeText :: Text
146
150
scopeText = case cScope of
147
151
GlobalConfig -> " --global"
148
152
LocalConfig -> " --local"
149
153
AutoConfig -> " "
150
154
155
+ newtype GPathToToolData
156
+ = GPathToToolData { name :: Text }
157
+
158
+ instance RenderGitCommand GPathToToolData where
159
+ toolName _ = " type"
160
+
161
+ commandArgs (GPathToToolData toolName') = [" -p" , toolName']
162
+
151
163
newtype GGPGKeyListData
152
164
= GGPGKeyListData { email :: Text }
153
165
@@ -175,7 +187,8 @@ data GitF a
175
187
| SetConfig GSetConfigData a
176
188
| UnsetConfig GUnsetConfigData a
177
189
| GPGListKeys GGPGKeyListData (Maybe (NonEmpty Text ) -> a )
178
- | Prompt Text (Maybe Text ) (Text -> a )
190
+ | PathToTool GPathToToolData (Maybe Text -> a )
191
+ | Prompt PromptConfig (Text -> a )
179
192
| FormatInfo Text (Text -> a )
180
193
| FormatCommand Text (Text -> a )
181
194
| PrintText Text a
@@ -205,6 +218,21 @@ data LogType
205
218
-- | Type alias to the `Free` `GitF` monad.
206
219
type FreeGit t = F GitF t
207
220
221
+
222
+ -- TODO: Make `OneTime` separate to improve the return type of the prompt
223
+ -- OneTime should return `Maybe Text` instead of `Text` to indicate 2 possible states.
224
+ -- Default would always return Text, as there is no possibity to go forward otherwise.
225
+ data PromptType
226
+ = PromptOneTime
227
+ | PromptDefault (Maybe Text )
228
+
229
+
230
+ data PromptConfig
231
+ = PromptConfig
232
+ { question :: Text
233
+ , promptType :: PromptType
234
+ }
235
+
208
236
-- | You should consider following code as a boilerplate
209
237
--
210
238
-- Each command should have the associated function to simplify the usage of this API.
@@ -254,8 +282,14 @@ unsetConfig cScope cName = liftF $ UnsetConfig (GUnsetConfigData cScope cName) (
254
282
gpgListKeys :: MonadFree GitF m => Text -> m (Maybe (NonEmpty Text ))
255
283
gpgListKeys gEmail = liftF $ GPGListKeys (GGPGKeyListData gEmail) id
256
284
285
+ pathToTool :: MonadFree GitF m => Text -> m (Maybe Text )
286
+ pathToTool toolName' = liftF $ PathToTool (GPathToToolData toolName') id
287
+
257
288
promptDefault :: MonadFree GitF m => Text -> Maybe Text -> m Text
258
- promptDefault pText pDefault = liftF $ Prompt pText pDefault id
289
+ promptDefault pText pDefault = liftF $ Prompt (PromptConfig pText (PromptDefault pDefault)) id
290
+
291
+ promptOneTime :: MonadFree GitF m => Text -> m Text
292
+ promptOneTime pText = liftF $ Prompt (PromptConfig pText PromptOneTime ) id
259
293
260
294
formatInfo :: MonadFree GitF m => Text -> m Text
261
295
formatInfo content = liftF $ FormatInfo content id
0 commit comments