Commit 75b7e050 authored by Lens0021's avatar Lens0021 🍂 Committed by Addshore
Browse files

mwdd: Handle errors from confirmation prompts

parent ea121a07
...@@ -90,23 +90,31 @@ var mwddMediawikiCmd = &cobra.Command{ ...@@ -90,23 +90,31 @@ var mwddMediawikiCmd = &cobra.Command{
if !mediawiki.MediaWikiIsPresent() { if !mediawiki.MediaWikiIsPresent() {
if !NoInteraction { if !NoInteraction {
cloneMwPrompt := promptui.Prompt{ cloneMwPrompt := promptui.Prompt{
Label: "MediaWiki code not detected in " + mwdd.Env().Get("MEDIAWIKI_VOLUMES_CODE") + ". Do you want to clone it now?", Label: "MediaWiki code not detected in " + mwdd.Env().Get("MEDIAWIKI_VOLUMES_CODE") + ". Do you want to clone it now? (Negative answers will abort this command)",
IsConfirm: true, IsConfirm: true,
} }
_, err := cloneMwPrompt.Run() if _, err := cloneMwPrompt.Run(); err != nil {
setupOpts.GetMediaWiki = err == nil fmt.Println("Can't continue without a MediaWiki code")
os.Exit(1)
} else {
setupOpts.GetMediaWiki = err != nil
}
} else { } else {
setupOpts.GetMediaWiki = true setupOpts.GetMediaWiki = true
} }
} }
if !mediawiki.VectorIsPresent() { if !mediawiki.VectorIsPresent() {
if !NoInteraction { if !NoInteraction {
cloneMwPrompt := promptui.Prompt{ cloneVectorPrompt := promptui.Prompt{
Label: "Vector skin is not detected in " + mwdd.Env().Get("MEDIAWIKI_VOLUMES_CODE") + ". Do you want to clone it from Gerrit?", Label: "Vector skin is not detected in " + mwdd.Env().Get("MEDIAWIKI_VOLUMES_CODE") + ". Do you want to clone it from Gerrit?",
IsConfirm: true, IsConfirm: true,
} }
_, err := cloneMwPrompt.Run() if _, err := cloneVectorPrompt.Run(); err == promptui.ErrInterrupt {
setupOpts.GetVector = err == nil fmt.Println("Keyboard interrupt detected. Shutting down.")
os.Exit(1)
} else {
setupOpts.GetVector = err != nil
}
} else { } else {
setupOpts.GetVector = true setupOpts.GetVector = true
} }
...@@ -117,15 +125,23 @@ var mwddMediawikiCmd = &cobra.Command{ ...@@ -117,15 +125,23 @@ var mwddMediawikiCmd = &cobra.Command{
Label: "Do you want to clone from Github for extra speed? (your git remotes will be switched to Gerrit after download)", Label: "Do you want to clone from Github for extra speed? (your git remotes will be switched to Gerrit after download)",
IsConfirm: true, IsConfirm: true,
} }
_, err := cloneFromGithubPrompt.Run() if _, err := cloneFromGithubPrompt.Run(); err == promptui.ErrInterrupt {
setupOpts.UseGithub = err == nil fmt.Println("Keyboard interrupt detected. Shutting down.")
os.Exit(1)
} else {
setupOpts.UseGithub = err != nil
}
cloneShallowPrompt := promptui.Prompt{ cloneShallowPrompt := promptui.Prompt{
Label: "Do you want to use shallow clones for extra speed? (You can fetch all history later using `git fetch --unshallow`)", Label: "Do you want to use shallow clones for extra speed? (You can fetch all history later using `git fetch --unshallow`)",
IsConfirm: true, IsConfirm: true,
} }
_, err = cloneShallowPrompt.Run() if _, err := cloneShallowPrompt.Run(); err == promptui.ErrInterrupt {
setupOpts.UseShallow = err == nil fmt.Println("Keyboard interrupt detected. Shutting down.")
os.Exit(1)
} else {
setupOpts.UseShallow = err != nil
}
finalRemoteTypePrompt := promptui.Prompt{ finalRemoteTypePrompt := promptui.Prompt{
Label: "How do you want to interact with Gerrit for the cloned repositores? (http or ssh)", Label: "How do you want to interact with Gerrit for the cloned repositores? (http or ssh)",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment