google / google/python-fire

Read variables from either the CLI or from the environment

Aberta
#106 3 comentários 4 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
28.2k
Forks
1.5k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hello,

I have been using Fire for a while now and in the last few days, it struck me that it may be nice to have a way to read a *required* variable either as an argument or as an environment variable.

The example that made me think about this was a simple script I wrote to execute some tasks in Facebook's API. It needs to receive both the _application id_ and _secret_. Sometimes I leave those as environment variables and sometimes I do not, depending on the machine that receives the deployed code.

I solved the issue by doing something like:

```python
from os import environ
from fire import Fire

APP_ID = environ.get('APP_ID')

def main(app_id=None):
assert app_id or APP_ID, 'You need to provide the app ID either as a parameter or as an environment variable'

if __name__ == '__main__':
Fire(main())
```

This got me wondering if it would be nice or even useful to implement something like this directly into Fire's variable handling. If so, I would love to contribute.

Thank you all very much :D

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece pelo ponto de entrada Fire(main()) e pelo comportamento da biblioteca em relação ao tratamento de variáveis e à análise de argumentos da CLI. Esclareça como os valores obrigatórios devem ser fornecidos por argumentos ou variáveis de ambiente, qual fonte tem precedência e como o preenchimento deve ser testado; a issue não nomeia arquivos ou testes específicos.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
cli
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.