Created
July 18, 2019 17:40
-
-
Save ducmeit1/209d140a79b64ef2ba6cf9d62792f73a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setNewConfig() error { | |
cfg, err := promptSetNewConfig() | |
if err != nil { | |
return err | |
} | |
err = pkg.WriteConfigFile(cfg) | |
if err != nil { | |
return err | |
} | |
fmt.Println("Override new configuration with details:") | |
fmt.Printf("MP3 Quality: %d\n"+ | |
"MP4 Quality: %d\n"+ | |
"Directory: %s", | |
cfg.Mp3Quality, cfg.Mp4Quality, cfg.GetDownloadFolder()) | |
return nil | |
} | |
func promptSetNewConfig() (*pkg.Config, error) { | |
cfg := &pkg.Config{} | |
mp3Quality, err := common.PromptInteger("MP3 Quality") | |
if err != nil { | |
return nil, err | |
} | |
if err := pkg.IsValidMP3Quality(mp3Quality); err != nil { | |
return nil, err | |
} | |
cfg.Mp3Quality = mp3Quality | |
mp4Quality, err := common.PromptInteger("MP4 Quality") | |
if err != nil { | |
return nil, err | |
} | |
if err := pkg.IsValidMP4Quality(mp4Quality); err != nil { | |
return nil, err | |
} | |
cfg.Mp4Quality = mp4Quality | |
directory, err := common.PromptString("Directory") | |
if err != nil { | |
return nil, err | |
} | |
cfg.Directory = directory | |
return cfg, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment