Skip to content
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

FAQ: CLI Configurations Best Practice #625

Open
francescobianca opened this issue Mar 7, 2022 · 1 comment
Open

FAQ: CLI Configurations Best Practice #625

francescobianca opened this issue Mar 7, 2022 · 1 comment

Comments

@francescobianca
Copy link

Hi,
what are the best practices for setting up configurations on the command line interface?
I give examples:

  • I have controllers that call methods of a service module:
# Controller module

@ex(help='Login command')
def login(self):
    username = shell.Prompt("Enter username:")
    password = getpass("Enter password: ")
    # password = shell.Prompt("Insert your password:")

    authentication_service.login(username.input, password)
# Authentication Service module

client_id = "..."
client_secret = "..."
keycloak_url = "..."
realm = "..."


def login(username, password):
    access_token = get_access_token(username, password)

All those parameters (client_id, client_secret etc) are like environment variables that every user can set (maybe in the cli setup phase).
My question is if the framework already has internal mechanisms to do this or do I have to create my own configuration files (.ini, .yaml etc) to edit each time? Are there any examples on this point?

System Information

  • Cement Version: Cement Framework 3.0.6
  • Python Version: Python 3.9.10
  • Operating System and Version: Platform Linux-5.13.0-1028-oem-x86_64-with

Thanks in advance

@derks
Copy link
Member

derks commented Mar 8, 2022

@francescobianca it sounds like you just want to use standard configuration settings, which is a built-in feature of Cement.

The document should answer any questions you have for usage, additionally... since you mentioned environment variables, these are honored by default to override config files as well:

Please let me know if that doesn't help or if you need further assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants