New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Envprofile auto-set in all console commands #244

Open
radutopala opened this Issue Jan 16, 2019 · 4 comments

Comments

@radutopala
Copy link

radutopala commented Jan 16, 2019

Envprofile should be transmitted automatically, somehow, to all Console commands.

This way we can avoid adding

        console.StringFlag{
            Name:  "envprofile, e", // long and short posix flag name
            Value: aah.App().Config().StringDefault("env.active", "dev"),           // default flag value
            Usage: "Environment profile name to activate (e.g: dev, prod)",
        },
    },

to every command.

The commands are part of the built binary, so it makes sense to have the envprofile in all commands as well.

A solution would be to append the EnvProfile StringFlag to Flags, when the command is added in init.

@jeevatkm

This comment has been minimized.

Copy link
Member

jeevatkm commented Jan 17, 2019

@radutopala Thanks for bringing up the suggestion for framework improvements.

I understand your proposed solution to add envprofile flag to all the commands implicitly. I'm wondering, does every command will be in the need of this flag? How to disable/remove this flag from particular command if aah user don't want it on the command?

I will do my homework and get back to you.

@jeevatkm

This comment has been minimized.

Copy link
Member

jeevatkm commented Jan 17, 2019

@radutopala I think, solution could be having a config to add envprofile flag into commands.

# Application binary console command's configurations.
console {
  # Convenient application binary flags configurations.
  flags {
    # Flag `envprofile`
    envprofile {
      # Add command/subcommand names into list to enable flag envprofile.
      # Framework would initialize app configuration based on flag `envprofile` input
      commands = ["cmd1", "cmd2", "cmd1.subcmd1", "cmd2.subcmd2"]
    }
  }
}

Please have a look and let me know. I will schedule it for v0.13.0 release.

@radutopala

This comment has been minimized.

Copy link
Author

radutopala commented Jan 17, 2019

@jeevatkm And these config defined flags will be auto-set also in the root command?

Even so, I don't think it's really necessary to have this level of abstraction. You would then need to be able to set different params in this configs entry for each flag, which I think should be done in code instead.

envprofile is already set in the root command by default. And the root's subcommands should have access to the same envprofile, because these subcommands are within the same app, the same context.

I think we just need a very simple solution here 😄just append the envprofile flag to all root's subcommands.

@jeevatkm

This comment has been minimized.

Copy link
Member

jeevatkm commented Jan 17, 2019

@radutopala Okay, lets start with simple design and could be improvised in the future.

Solution is -

Add envprofile flag into command when aah user register into application via aah.App().AddCommand(...). Initialize the app configuration based on the flag input and make available to the command.

@jeevatkm jeevatkm self-assigned this Jan 18, 2019

@jeevatkm jeevatkm added this to the v0.13.0 Milestone milestone Jan 18, 2019

@jeevatkm jeevatkm added this to v0.13.0 - Iteration in aah Roadmap via automation Jan 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment