run Function

public function run(cli) result(status)

Format the paths of cli and return the exit status.

Arguments

Type IntentOptional Attributes Name
type(cli_t), intent(in) :: cli

the parsed command line

Return Value integer


Calls

proc~~run~~CallsGraph proc~run run proc~directory_files directory_files proc~run->proc~directory_files proc~is_directory is_directory proc~run->proc~is_directory proc~process_file process_file proc~run->proc~process_file proc~process_stdin process_stdin proc~run->proc~process_stdin proc~usage usage proc~run->proc~usage proc~absolute_path absolute_path proc~directory_files->proc~absolute_path proc~collect_files collect_files proc~directory_files->proc~collect_files proc~config_for config_for proc~directory_files->proc~config_for proc~default_exclude default_exclude proc~directory_files->proc~default_exclude proc~default_extensions default_extensions proc~directory_files->proc~default_extensions interface~c_closedir c_closedir proc~is_directory->interface~c_closedir interface~c_opendir c_opendir proc~is_directory->interface~c_opendir proc~c_string c_string proc~is_directory->proc~c_string proc~process_file->proc~absolute_path proc~parent_directory parent_directory proc~process_file->proc~parent_directory proc~process_text process_text proc~process_file->proc~process_text proc~read_file read_file proc~process_file->proc~read_file proc~process_stdin->proc~process_text proc~read_stdin read_stdin proc~process_stdin->proc~read_stdin proc~current_directory current_directory proc~absolute_path->proc~current_directory proc~is_absolute is_absolute proc~absolute_path->proc~is_absolute proc~join_path join_path proc~absolute_path->proc~join_path fullmatch fullmatch proc~collect_files->fullmatch proc~child child proc~collect_files->proc~child proc~glob_to_regex glob_to_regex proc~collect_files->proc~glob_to_regex proc~list_directory list_directory proc~collect_files->proc~list_directory proc~sort_entries sort_entries proc~collect_files->proc~sort_entries regex regex proc~collect_files->regex proc~ends_with ends_with proc~config_for->proc~ends_with proc~find_config find_config proc~config_for->proc~find_config proc~load_config load_config proc~config_for->proc~load_config proc~format_text format_text proc~process_text->proc~format_text proc~options_for options_for proc~process_text->proc~options_for proc~to_s to_s proc~process_text->proc~to_s proc~unified_diff unified_diff proc~process_text->proc~unified_diff proc~write_file write_file proc~process_text->proc~write_file proc~builder_append string_builder_t%builder_append proc~read_stdin->proc~builder_append proc~builder_get string_builder_t%builder_get proc~read_stdin->proc~builder_get proc~child->proc~join_path interface~c_getcwd c_getcwd proc~current_directory->interface~c_getcwd proc~find_config->proc~parent_directory proc~find_config->proc~join_path proc~find_config->proc~load_config proc~empty empty proc~find_config->proc~empty proc~format_text->proc~to_s proc~convert_relational convert_relational proc~format_text->proc~convert_relational proc~format_pass format_pass proc~format_text->proc~format_pass proc~limit_diagnostics limit_diagnostics proc~format_text->proc~limit_diagnostics proc~long_code_lines long_code_lines proc~format_text->proc~long_code_lines proc~relayout relayout proc~format_text->proc~relayout proc~sort_use sort_use proc~format_text->proc~sort_use proc~split_long_lines split_long_lines proc~format_text->proc~split_long_lines proc~tokenize tokenize proc~format_text->proc~tokenize proc~too_long too_long proc~format_text->proc~too_long re_escape re_escape proc~glob_to_regex->re_escape proc~list_directory->proc~is_directory proc~list_directory->interface~c_closedir proc~list_directory->interface~c_opendir proc~list_directory->proc~c_string proc~list_directory->proc~join_path interface~c_readdir c_readdir proc~list_directory->interface~c_readdir proc~byte_at byte_at proc~list_directory->proc~byte_at proc~entry_name entry_name proc~list_directory->proc~entry_name proc~find_layout find_layout proc~list_directory->proc~find_layout proc~load_config->proc~to_s get get proc~load_config->get get_keys get_keys proc~load_config->get_keys get_type get_type proc~load_config->get_type get_value get_value proc~load_config->get_value proc~load_config->proc~empty toml_load toml_load proc~load_config->toml_load proc~options_for->proc~absolute_path proc~options_for->proc~config_for proc~apply_setting apply_setting proc~options_for->proc~apply_setting proc~unified_diff->proc~builder_append proc~unified_diff->proc~builder_get proc~lcs lcs proc~unified_diff->proc~lcs proc~line_ids line_ids proc~unified_diff->proc~line_ids proc~range_text range_text proc~unified_diff->proc~range_text proc~split_lines split_lines proc~unified_diff->proc~split_lines proc~apply_setting->proc~to_s proc~convert_relational->proc~builder_append proc~convert_relational->proc~builder_get proc~is_chevron is_chevron proc~convert_relational->proc~is_chevron proc~parse_source parse_source proc~convert_relational->proc~parse_source proc~token_lower token_lower proc~convert_relational->proc~token_lower proc~token_text token_text proc~convert_relational->proc~token_text proc~find_layout->interface~c_closedir proc~find_layout->interface~c_opendir proc~find_layout->proc~c_string proc~find_layout->interface~c_readdir proc~find_layout->proc~byte_at proc~format_pass->proc~to_s proc~analyze_structure analyze_structure proc~format_pass->proc~analyze_structure proc~compute_case compute_case proc~format_pass->proc~compute_case proc~compute_gaps compute_gaps proc~format_pass->proc~compute_gaps proc~layout layout proc~format_pass->proc~layout proc~format_pass->proc~parse_source proc~set_views set_views proc~format_pass->proc~set_views proc~lcs->proc~lcs proc~lcs_lengths lcs_lengths proc~lcs->proc~lcs_lengths proc~limit_diagnostics->proc~to_s proc~longest_line longest_line proc~limit_diagnostics->proc~longest_line proc~limit_diagnostics->proc~parse_source proc~hash hash proc~line_ids->proc~hash proc~long_code_lines->proc~parse_source proc~utf8_width utf8_width proc~long_code_lines->proc~utf8_width proc~range_text->proc~to_s proc~relayout->proc~builder_append proc~relayout->proc~builder_get proc~relayout->proc~format_pass proc~sort_use->proc~builder_append proc~sort_use->proc~builder_get proc~is_use_statement is_use_statement proc~sort_use->proc~is_use_statement proc~module_key module_key proc~sort_use->proc~module_key proc~sort_use->proc~parse_source proc~set_view set_view proc~sort_use->proc~set_view proc~sort_only_list sort_only_list proc~sort_use->proc~sort_only_list proc~sorted_order sorted_order proc~sort_use->proc~sorted_order proc~whole_lines whole_lines proc~sort_use->proc~whole_lines proc~split_long_lines->proc~builder_append proc~split_long_lines->proc~builder_get proc~break_point break_point proc~split_long_lines->proc~break_point proc~builder_length string_builder_t%builder_length proc~split_long_lines->proc~builder_length proc~split_long_lines->proc~parse_source proc~stands_alone stands_alone proc~split_long_lines->proc~stands_alone proc~split_long_lines->proc~token_text proc~split_long_lines->proc~utf8_width proc~add add proc~tokenize->proc~add proc~comment_kind comment_kind proc~tokenize->proc~comment_kind proc~dotop_at dotop_at proc~tokenize->proc~dotop_at proc~dotop_end dotop_end proc~tokenize->proc~dotop_end proc~fypp_inline_end fypp_inline_end proc~tokenize->proc~fypp_inline_end proc~is_blank is_blank proc~tokenize->proc~is_blank proc~is_digit is_digit proc~tokenize->proc~is_digit proc~is_preproc_start is_preproc_start proc~tokenize->proc~is_preproc_start proc~is_quote is_quote proc~tokenize->proc~is_quote proc~lex_number lex_number proc~tokenize->proc~lex_number proc~line_end line_end proc~tokenize->proc~line_end proc~name_end name_end proc~tokenize->proc~name_end proc~operator_end operator_end proc~tokenize->proc~operator_end proc~peek peek proc~tokenize->proc~peek proc~preproc_end preproc_end proc~tokenize->proc~preproc_end proc~string_end string_end proc~tokenize->proc~string_end proc~longest_code longest_code proc~too_long->proc~longest_code proc~add->proc~is_blank proc~add->proc~peek proc~is_code_char is_code_char proc~add->proc~is_code_char proc~push~2 token_list_t%push proc~add->proc~push~2 proc~analyze_structure->proc~to_s proc~analyze_structure->proc~token_lower proc~classify_statement classify_statement proc~analyze_structure->proc~classify_statement proc~closes closes proc~analyze_structure->proc~closes proc~conditional_kind conditional_kind proc~analyze_structure->proc~conditional_kind proc~construct_label construct_label proc~analyze_structure->proc~construct_label proc~fypp_depths fypp_depths proc~analyze_structure->proc~fypp_depths proc~middle_fits middle_fits proc~analyze_structure->proc~middle_fits proc~stack_push scope_stack_t%stack_push proc~analyze_structure->proc~stack_push proc~stack_restore scope_stack_t%stack_restore proc~analyze_structure->proc~stack_restore proc~stack_snapshot scope_stack_t%stack_snapshot proc~analyze_structure->proc~stack_snapshot proc~break_point->proc~token_lower proc~break_point->proc~token_text proc~break_point->proc~utf8_width proc~priority priority proc~break_point->proc~priority proc~comment_kind->proc~peek proc~is_letter is_letter proc~comment_kind->proc~is_letter proc~lowercase lowercase proc~comment_kind->proc~lowercase proc~kind_part kind_part proc~compute_case->proc~kind_part proc~names_case names_case proc~compute_case->proc~names_case proc~statement_case statement_case proc~compute_case->proc~statement_case proc~comment_gaps comment_gaps proc~compute_gaps->proc~comment_gaps proc~statement_gaps statement_gaps proc~compute_gaps->proc~statement_gaps proc~dotop_at->proc~peek proc~dotop_at->proc~is_letter proc~dotop_end->proc~name_end proc~dotop_end->proc~peek proc~is_name_char is_name_char proc~dotop_end->proc~is_name_char proc~dotop_end->proc~lowercase proc~fypp_inline_end->proc~peek proc~is_preproc_start->proc~peek proc~layout->proc~builder_get proc~emit_blank emit_blank proc~layout->proc~emit_blank proc~emit_comment_line emit_comment_line proc~layout->proc~emit_comment_line proc~emit_fypp_line emit_fypp_line proc~layout->proc~emit_fypp_line proc~emit_range emit_range proc~layout->proc~emit_range proc~emit_statement emit_statement proc~layout->proc~emit_statement proc~lex_number->proc~dotop_at proc~lex_number->proc~is_digit proc~lex_number->proc~name_end proc~lex_number->proc~peek proc~digits_end digits_end proc~lex_number->proc~digits_end proc~lex_number->proc~is_name_char proc~lower_char lower_char proc~lex_number->proc~lower_char proc~view_word statement_view_t%view_word proc~module_key->proc~view_word proc~name_end->proc~peek proc~name_end->proc~is_name_char proc~parse_source->proc~tokenize proc~protected_items protected_items proc~parse_source->proc~protected_items proc~split_statements split_statements proc~parse_source->proc~split_statements proc~preproc_end->proc~line_end proc~preproc_end->proc~peek proc~last_nonblank last_nonblank proc~preproc_end->proc~last_nonblank proc~make_lowercase make_lowercase proc~set_view->proc~make_lowercase proc~set_views->proc~set_view proc~sort_only_list->proc~builder_append proc~sort_only_list->proc~builder_get proc~sort_only_list->proc~sorted_order proc~sort_only_list->proc~token_text proc~only_items only_items proc~sort_only_list->proc~only_items proc~sort_only_list->proc~view_word proc~string_end->proc~is_blank proc~string_end->proc~line_end proc~string_end->proc~peek proc~only_blanks_to_eol only_blanks_to_eol proc~string_end->proc~only_blanks_to_eol proc~token_lower->proc~make_lowercase proc~closed_construct closed_construct proc~classify_statement->proc~closed_construct proc~expand_keyword expand_keyword proc~classify_statement->proc~expand_keyword proc~read_label read_label proc~classify_statement->proc~read_label proc~set set proc~classify_statement->proc~set proc~view_closing statement_view_t%view_closing proc~classify_statement->proc~view_closing proc~view_kind_of statement_view_t%view_kind_of proc~classify_statement->proc~view_kind_of proc~comment_gaps->proc~utf8_width proc~digits_end->proc~is_digit proc~digits_end->proc~peek proc~emit_blank->proc~token_text proc~put put proc~emit_blank->proc~put proc~emit_comment_line->proc~token_text proc~emit_comment_line->proc~emit_range proc~comment_column comment_column proc~emit_comment_line->proc~comment_column proc~input_column input_column proc~emit_comment_line->proc~input_column proc~emit_comment_line->proc~put proc~trim_blanks trim_blanks proc~emit_comment_line->proc~trim_blanks proc~emit_fypp_line->proc~emit_range proc~first_non_blank first_non_blank proc~emit_fypp_line->proc~first_non_blank proc~emit_fypp_line->proc~put proc~emit_range->proc~token_text proc~emit_range->proc~put proc~emit_statement->proc~token_lower proc~emit_statement->proc~token_text proc~emit_statement->proc~emit_range proc~emit_statement->proc~comment_column proc~continuation_target continuation_target proc~emit_statement->proc~continuation_target proc~emit_body emit_body proc~emit_statement->proc~emit_body proc~emit_continuation emit_continuation proc~emit_statement->proc~emit_continuation proc~emit_statement->proc~first_non_blank proc~fitting_column fitting_column proc~emit_statement->proc~fitting_column proc~emit_statement->proc~input_column proc~emit_statement->proc~put proc~fypp_depths->proc~token_lower proc~fypp_kind fypp_kind proc~fypp_depths->proc~fypp_kind proc~is_code_char->proc~is_blank proc~is_name_char->proc~is_digit proc~is_name_char->proc~is_letter proc~last_nonblank->proc~is_blank proc~lowercase->proc~lower_char proc~names_case->proc~view_word proc~names_case->proc~view_kind_of proc~only_blanks_to_eol->proc~line_end proc~only_blanks_to_eol->proc~last_nonblank proc~directive directive proc~protected_items->proc~directive proc~ends_with_continuation ends_with_continuation proc~split_statements->proc~ends_with_continuation proc~find_semicolon find_semicolon proc~split_statements->proc~find_semicolon proc~line_end_token line_end_token proc~split_statements->proc~line_end_token proc~line_kind line_kind proc~split_statements->proc~line_kind proc~push statement_list_t%push proc~split_statements->proc~push proc~stack_restore->proc~stack_push proc~statement_case->proc~view_word proc~statement_case->proc~view_closing proc~statement_case->proc~view_kind_of proc~statement_gaps->proc~is_chevron proc~statement_gaps->proc~view_word proc~is_word is_word proc~statement_gaps->proc~is_word proc~statement_gaps->proc~view_kind_of proc~comment_column->proc~fitting_column proc~comment_column->proc~input_column proc~directive->proc~token_text proc~emit_body->proc~token_lower proc~emit_body->proc~kind_part proc~emit_body->proc~input_column proc~emit_body->proc~put proc~line_pieces line_pieces proc~emit_body->proc~line_pieces proc~to_case to_case proc~emit_body->proc~to_case proc~emit_continuation->proc~emit_body proc~emit_continuation->proc~first_non_blank proc~emit_continuation->proc~fitting_column proc~emit_continuation->proc~input_column proc~emit_continuation->proc~put proc~first_piece_width first_piece_width proc~fitting_column->proc~first_piece_width proc~line_width line_width proc~fitting_column->proc~line_width proc~input_column->proc~utf8_width proc~put->proc~builder_append proc~put->proc~utf8_width proc~first_piece_width->proc~utf8_width proc~first_piece_width->proc~line_pieces proc~line_width->proc~utf8_width proc~line_width->proc~line_pieces

Source Code

integer function run(cli) result(status)
    !! Format the paths of `cli` and return the exit status.
    type(cli_t), intent(in) :: cli      !! the parsed command line
    type(config_cache_t) :: cache
    type(string_t), allocatable :: files(:)
    integer :: k, j

    if (cli%help) then
        write (output_unit, '(a)') usage()
        status = EXIT_OK
        return
    end if
    if (cli%version) then
        write (output_unit, '(a)') 'fformat '//VERSION
        status = EXIT_OK
        return
    end if
    allocate (cache%dirs(0), cache%configs(0))
    status = EXIT_OK
    do k = 1, size(cli%paths)
        associate (path => cli%paths(k)%s)
            if (path == '-') then
                status = max(status, process_stdin(cli, cache))
            else if (is_directory(path)) then
                call directory_files(cli, cache, path, files, status)
                do j = 1, size(files)
                    status = max(status, process_file(cli, cache, files(j)%s))
                end do
            else
                status = max(status, process_file(cli, cache, path))
            end if
        end associate
    end do
end function run