mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
config-patch: update to new commands lib
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
@ -295,7 +295,7 @@ can't be undone.
|
|||||||
}
|
}
|
||||||
|
|
||||||
var configProfileCmd = &cmds.Command{
|
var configProfileCmd = &cmds.Command{
|
||||||
Helptext: cmds.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
Tagline: "Apply profiles to config.",
|
Tagline: "Apply profiles to config.",
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -306,48 +306,48 @@ var configProfileCmd = &cmds.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var configProfileApplyCmd = &cmds.Command{
|
var configProfileApplyCmd = &cmds.Command{
|
||||||
Helptext: cmds.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
Tagline: "Apply profile to config.",
|
Tagline: "Apply profile to config.",
|
||||||
},
|
},
|
||||||
Arguments: []cmds.Argument{
|
Arguments: []cmdkit.Argument{
|
||||||
cmds.StringArg("profile", true, false, "The profile to apply to the config."),
|
cmdkit.StringArg("profile", true, false, "The profile to apply to the config."),
|
||||||
},
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
profile, ok := config.Profiles[req.Arguments()[0]]
|
profile, ok := config.Profiles[req.Arguments()[0]]
|
||||||
if !ok {
|
if !ok {
|
||||||
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmds.ErrNormal)
|
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmdkit.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := transformConfig(req.InvocContext().ConfigRoot, profile.Apply)
|
err := transformConfig(req.InvocContext().ConfigRoot, profile.Apply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmdkit.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var configProfileRevertCmd = &cmds.Command{
|
var configProfileRevertCmd = &cmds.Command{
|
||||||
Helptext: cmds.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
Tagline: "Revert profile changes.",
|
Tagline: "Revert profile changes.",
|
||||||
ShortDescription: `Reverts profile-related changes to the config.
|
ShortDescription: `Reverts profile-related changes to the config.
|
||||||
|
|
||||||
Reverting some profiles may damage the configuration or not be possible.
|
Reverting some profiles may damage the configuration or not be possible.
|
||||||
Backing up the config before running this command is advised.`,
|
Backing up the config before running this command is advised.`,
|
||||||
},
|
},
|
||||||
Arguments: []cmds.Argument{
|
Arguments: []cmdkit.Argument{
|
||||||
cmds.StringArg("profile", true, false, "The profile to apply to the config."),
|
cmdkit.StringArg("profile", true, false, "The profile to apply to the config."),
|
||||||
},
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
profile, ok := config.Profiles[req.Arguments()[0]]
|
profile, ok := config.Profiles[req.Arguments()[0]]
|
||||||
if !ok {
|
if !ok {
|
||||||
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmds.ErrNormal)
|
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmdkit.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := transformConfig(req.InvocContext().ConfigRoot, profile.Revert)
|
err := transformConfig(req.InvocContext().ConfigRoot, profile.Revert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmdkit.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user