theurichde / go-aws-sso

Makes dealing with AWS SSO Logins an ease
MIT License
111 stars 15 forks source link

feat: allow config generation without user prompt #105

Closed fishgrimsby closed 1 year ago

fishgrimsby commented 1 year ago

This PR will allow a config file to be generated without prompting the user for answers if they provide --start-url or --region as command options to config generate. If either one or both of these are omitted the user is prompted for an answer in the usual way.

It is an attempted implementation for #104

fishgrimsby commented 1 year ago

@theurichde Thanks for looking so promptly. You're absolutely right, it makes no sense to pass them all! I'll have a play and push some changes

fishgrimsby commented 1 year ago

@theurichde I've made a change as requested. It's perhaps not quite as you suggested as I didn't understand about appending it later. If it does need doing a different way then let me know and I'll give it a go!

theurichde commented 1 year ago

Hi @fishgrimsby!

What I meant by appending the flags, is, that you could have added those both flags into a separate configFlags slice, pass those to the GenerateConfigAction and append them directly to initialFlags like below:

configFlags := []cli.Flag{ [startURL and region here] }
initialFlags := []cli.Flag{ [all other needed flags go here] }
initialFlags = append(initialFlags, configFlags...)

This would be less errorprone as your current implementation depends on the order of the flags added, which could break when a new flag gets inserted before the e.g. start-url flag

fishgrimsby commented 1 year ago

@theurichde That makes sense, I think i was taking the word extract too literally 😄 I've made the change as you suggested, I've reversed the order of the append to maintain the order of the initflags. Thanks for the help! 👍

theurichde commented 1 year ago

Thank you! Merge incoming 🎈