Beispiel #1
0
def prompt(args):
    segments = {
        'current_working_path': current_working_path.segment(),
        'git_active_branch': repository.ActiveBranch(os.getcwd()).segment(),
        'git_is_dirty': repository.IsDirty(os.getcwd()).segment(),
        'virtual_env': virtual_env.segment(),
        'prompt_symbol': prompt_symbol.segment(args.last_command_status)
    }

    if args.json:
        [print(jsonify(segment)) for segment in segments.values()]
        return [jsonify(segment) for segment in segments.values()]
    else:
        segments_with_style = {}
        [segments_with_style.update({name: "{style}{text}".format(**segment)}) for name, segment in segments.items()]
        print(layout().format(**segments_with_style), end='')
Beispiel #2
0
def test_prompt_symbol_is_colored_for_failed_command():
    colors.load_theme()

    symbol = prompt.fetch(prompt_symbol.segment(constants.FAIL))

    assert symbol in colorful.danger('❯').styled_string
Beispiel #3
0
def test_prompt_symbol_is_colored_for_successful_command():
    colors.load_theme()
    
    symbol = prompt.fetch(prompt_symbol.segment(constants.SUCCESS))

    assert symbol in colorful.primary('❯').styled_string
Beispiel #4
0
def test_prompt_symbol_segment_contains_text_and_style():
    colors.load_theme()
    segment = prompt_symbol.segment()

    assert segment == {'text': '❯', 'style': colors.style('primary')}
Beispiel #5
0
def test_prompt_symbol_segment_contains_text_and_danger_color_when_last_command_failed(
):
    colors.load_theme()
    segment = prompt_symbol.segment(last_command_status=constants.FAIL)

    assert segment == {'text': '❯', 'style': colors.style('danger')}
Beispiel #6
0
def test_prompt_symbol_segment_contains_text_and_primary_color_when_last_command_succeed(
):
    colors.load_theme()
    segment = prompt_symbol.segment(last_command_status=constants.SUCCESS)

    assert segment == {'text': '❯', 'style': colors.style('primary')}