Exemple #1
0
except ImportError:
    sys.stderr.write('It seems python-dotenv is not installed with cli option. \n'
                     'Run pip install "python-dotenv[cli]" to fix this.')
    sys.exit(1)

from .compat import IS_TYPE_CHECKING, to_env
from .main import dotenv_values, get_key, set_key, unset_key
from .version import __version__

if IS_TYPE_CHECKING:
    from typing import Any, List, Dict


@click.group()
@click.option('-f', '--file', default=os.path.join(os.getcwd(), '.env'),
              type=click.Path(exists=True),
              help="Location of the .env file, defaults to .env file in current working directory.")
@click.option('-q', '--quote', default='always',
              type=click.Choice(['always', 'never', 'auto']),
              help="Whether to quote or not the variable values. Default mode is always. This does not affect parsing.")
@click.version_option(version=__version__)
@click.pass_context
def cli(ctx, file, quote):
    # type: (click.Context, Any, Any) -> None
    '''This script is used to set, get or unset values from a .env file.'''
    ctx.obj = {}
    ctx.obj['FILE'] = file
    ctx.obj['QUOTE'] = quote


@cli.command()
Exemple #2
0
    "-l",
    default=None,
    help="a loader identifier to filter e.g: toml|yaml",
)
@click.option(
    "--all",
    "_all",
    "-a",
    default=False,
    is_flag=True,
    help="show dynaconf internal settings?",
)
@click.option(
    "--output",
    "-o",
    type=click.Path(writable=True, dir_okay=False),
    default=None,
    help="Filepath to write the listed values as json",
)
@click.option(
    "--output-flat",
    "flat",
    is_flag=True,
    default=False,
    help="Output file is flat (do not include [env] name)",
)
def _list(env, key, more, loader, _all=False, output=None, flat=False):
    """Lists all user defined config values
    and if `--all` is passed it also shows dynaconf internal variables.
    """
    if env:
    sys.stderr.write(
        'It seems python-dotenv is not installed with cli option. \nRun pip install "python-dotenv[cli]" to fix this.'
    )
    sys.exit(1)
from .compat import IS_TYPE_CHECKING, to_env
from .main import dotenv_values, get_key, set_key, unset_key
from .version import __version__
if IS_TYPE_CHECKING: from typing import Any, List, Dict


@click.group()
@click.option(
    '-f',
    '--file',
    default=os.path.join(os.getcwd(), '.env'),
    type=click.Path(exists=_A),
    help=
    'Location of the .env file, defaults to .env file in current working directory.'
)
@click.option(
    '-q',
    '--quote',
    default=_F,
    type=click.Choice([_F, 'never', 'auto']),
    help=
    'Whether to quote or not the variable values. Default mode is always. This does not affect parsing.'
)
@click.version_option(version=__version__)
@click.pass_context
def cli(ctx, file, quote):
    A = ctx