parse_arguments_with_stdin_check Subroutine

public subroutine parse_arguments_with_stdin_check(filename, show_help, verbose_level, custom_cache_dir, custom_config_dir, parallel_jobs, no_wait, notebook_mode, notebook_output, standardize_only, clear_cache, cache_info, debug_tokens, debug_ast, debug_semantic, debug_standardize, debug_codegen, from_tokens, from_ast, from_semantic, has_stdin, nargs_override)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(out) :: filename
logical, intent(out) :: show_help
integer, intent(out) :: verbose_level
character(len=*), intent(out) :: custom_cache_dir
character(len=*), intent(out) :: custom_config_dir
integer, intent(out) :: parallel_jobs
logical, intent(out) :: no_wait
logical, intent(out) :: notebook_mode
character(len=*), intent(out) :: notebook_output
logical, intent(out) :: standardize_only
logical, intent(out) :: clear_cache
logical, intent(out) :: cache_info
logical, intent(out) :: debug_tokens
logical, intent(out) :: debug_ast
logical, intent(out) :: debug_semantic
logical, intent(out) :: debug_standardize
logical, intent(out) :: debug_codegen
logical, intent(out) :: from_tokens
logical, intent(out) :: from_ast
logical, intent(out) :: from_semantic
logical, intent(in) :: has_stdin
integer, intent(in) :: nargs_override

Source Code

    subroutine parse_arguments_with_stdin_check(filename, show_help, verbose_level, &
                                                custom_cache_dir, custom_config_dir, &
                                                parallel_jobs, no_wait, notebook_mode, &
                                                notebook_output, standardize_only, &
                                                clear_cache, cache_info, debug_tokens, &
                          debug_ast, debug_semantic, debug_standardize, debug_codegen, &
                                                from_tokens, from_ast, from_semantic, &
                                                has_stdin, nargs_override)
        character(len=*), intent(out) :: filename
        logical, intent(out) :: show_help
        integer, intent(out) :: verbose_level
        character(len=*), intent(out) :: custom_cache_dir, custom_config_dir
        integer, intent(out) :: parallel_jobs
        logical, intent(out) :: no_wait, notebook_mode, standardize_only
        character(len=*), intent(out) :: notebook_output
        logical, intent(out) :: clear_cache, cache_info
        logical, intent(out) :: debug_tokens, debug_ast, debug_semantic, debug_standardize, debug_codegen
        logical, intent(out) :: from_tokens, from_ast, from_semantic
        logical, intent(in) :: has_stdin
        integer, intent(in) :: nargs_override

        ! This is a testable version that allows mocking STDIN and arg count

        ! If nargs_override is negative, use actual command arg count
        integer :: actual_nargs
        if (nargs_override < 0) then
            actual_nargs = command_argument_count()
        else
            actual_nargs = nargs_override
        end if

        if (actual_nargs == 0) then
            if (has_stdin) then
                ! No arguments but STDIN available - use STDIN
                filename = '-'
                show_help = .false.
                ! Set defaults for all other parameters
                verbose_level = 0
                custom_cache_dir = ''
                custom_config_dir = ''
                parallel_jobs = 0
                no_wait = .false.
                notebook_mode = .false.
                notebook_output = ''
                standardize_only = .false.
                clear_cache = .false.
                cache_info = .false.
                debug_tokens = .false.
                debug_ast = .false.
                debug_semantic = .false.
                debug_standardize = .false.
                debug_codegen = .false.
                from_tokens = .false.
                from_ast = .false.
                from_semantic = .false.
            else
                ! No arguments and no STDIN - show help
                show_help = .true.
                return
            end if
        else
            ! Has arguments - use normal parsing
            call parse_arguments(filename, show_help, verbose_level, custom_cache_dir, &
                             custom_config_dir, parallel_jobs, no_wait, notebook_mode, &
                             notebook_output, standardize_only, custom_flags=filename, &
                                 clear_cache=clear_cache, cache_info=cache_info, &
                                 debug_tokens=debug_tokens, debug_ast=debug_ast, &
                   debug_semantic=debug_semantic, debug_standardize=debug_standardize, &
                                 debug_codegen=debug_codegen, from_tokens=from_tokens, &
                                 from_ast=from_ast, from_semantic=from_semantic)
        end if

    end subroutine parse_arguments_with_stdin_check