How to use the invocations.console.confirm function in invocations

To help you get started, we’ve selected a few invocations examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyinvoke / invocations / tests / console.py View on Github external
def reprompts_on_bad_input(self, mock_input):
        assert confirm("O rly?") is True
        assert "I didn't understand you" in sys.stderr.getvalue()
github pyinvoke / invocations / tests / console.py View on Github external
def suffix_changes_when_assume_yes_False(self, mock_input):
        confirm("Are you sure?", assume_yes=False)
        assert mock_input.call_args[0][0] == "Are you sure? [y/N] "
github pyinvoke / invocations / tests / console.py View on Github external
def displays_question_with_yes_no_suffix(self, mock_input):
        confirm("Are you sure?")
        assert mock_input.call_args[0][0] == "Are you sure? [Y/n] "
github pyinvoke / invocations / tests / console.py View on Github external
def default_on_empty_response_is_True_by_default(self, mock_input):
        assert confirm("Are you sure?") is True
github pyinvoke / invocations / tests / console.py View on Github external
def whitespace_is_trimmed(self, mock_input):
        assert confirm("Are you sure?") is True
github pyinvoke / invocations / tests / console.py View on Github external
def default_on_empty_response_is_False_if_assume_yes_False(
        self, mock_input
    ):
        assert confirm("Are you sure?", assume_yes=False) is False
github pyinvoke / invocations / tests / console.py View on Github external
def returns_False_for_nolike_responses(self, mock_input):
        for value in ("n", "N", "no", "NO", "nO", "No"):
            mock_input.return_value = value
            assert confirm("Meh") is False
github pyinvoke / invocations / tests / console.py View on Github external
def returns_True_for_yeslike_responses(self, mock_input):
        for value in ("y", "Y", "yes", "YES", "yES", "Yes"):
            mock_input.return_value = value
            assert confirm("Meh") is True
github powdahound / ec2instances.info / tasks.py View on Github external
def bucket_delete(c):
    """Deletes the S3 bucket used to host the site"""
    if not confirm("Are you sure you want to delete the bucket %r?" % BUCKET_NAME):
        print('Aborting at user request.')
        exit(1)
    conn = connect_s3(calling_format=BUCKET_CALLING_FORMAT)
    conn.delete_bucket(BUCKET_NAME)
    print('Bucket %r deleted.' % BUCKET_NAME)
github pyinvoke / invocations / invocations / packaging / release.py View on Github external
def all_(c):
    """
    Catchall version-bump/tag/changelog/PyPI upload task.
    """
    # Print dry-run/status/actions-to-take data & grab programmatic result
    # TODO: maybe expand the enum-based stuff to have values that split up
    # textual description, command string, etc. See the TODO up by their
    # definition too, re: just making them non-enum classes period.
    # TODO: otherwise, we at least want derived eg changelog/version/etc paths
    # transmitted from status() into here...
    actions, state = status(c)
    # TODO: unless nothing-to-do in which case just say that & exit 0
    if not confirm("Take the above actions?"):
        sys.exit("Aborting.")

    # TODO: factor out what it means to edit a file:
    # - $EDITOR or explicit expansion of it in case no shell involved
    # - pty=True and hide=False, because otherwise things can be bad
    # - what else?

    # Changelog! (pty for non shite editing, eg vim sure won't like non-pty)
    if actions.changelog is Changelog.NEEDS_RELEASE:
        # TODO: identify top of list and inject a ready-made line? Requires vim
        # assumption...GREAT opportunity for class/method based tasks!
        cmd = "$EDITOR {0.packaging.changelog_file}".format(c)
        c.run(cmd, pty=True, hide=False)
    # TODO: add a step for checking reqs.txt / setup.py vs virtualenv contents
    # Version file!
    if actions.version == VersionFile.NEEDS_BUMP: