App-DBBrowser

 view release on metacpan or  search on metacpan

lib/App/DBBrowser/Options/Menus.pm  view on Meta::CPAN

    }
    else {
        $groups = [
            { name => 'group_global', text => "- Global settings" },
        ];
    }
    return $groups;
}


sub sub_groups {
    my ( $sf, $group, $driver ) = @_;
    if ( $group eq 'group_connect' ) {
        if ( $driver =~ /^(?:SQLite|DuckDB)\z/ ) {
            return [
                { name => '_read_attributes',   text => "- Read attributes",    section => 'connect_attr' },
                { name => '_set_attributes',    text => "- Set attributes",     section => 'connect_attr' },
            ];
        }
        else {
            return [
                { name => '_required_fields',   text => "- Required fields",    section => 'connect_data' },
                { name => '_login_data',        text => "- Login data",         section => 'connect_data' },
                { name => '_env_variables',     text => "- ENV variables",      section => 'connect_data' },
                { name => '_read_attributes',   text => "- Read attributes",    section => 'connect_attr' },
                { name => '_set_attributes',    text => "- Set attributes",     section => 'connect_attr' },
            ];
        }
    }
    my $groups = {
        group_extensions => [
            { name => '_e_table',        text => "- Tables menu",        section => 'enable' },
            { name => '_e_join',         text => "- Join menu",          section => 'enable' },
            { name => '_e_union',        text => "- Union menu",         section => 'enable' },
            { name => '_e_expressions',  text => "- Columns and Values", section => 'enable' },
            { name => '_e_write_access', text => "- Write access",       section => 'enable' },
        ],
        group_sql_settings => [
            { name => '_meta',               text => "- System data",      section => 'G'      },
            { name => 'operators',           text => "- Operators",        section => 'G'      },
            { name => '_add_aliases',        text => "- Add aliases",      section => 'alias'  },
            { name => '_aliases_in_clauses', text => "- Alias in clauses", section => 'alias'  },
            { name => '_sql_identifiers',    text => "- Identifiers",      section => 'G'      },
            { name => '_view_name_prefix',   text => "- View prefix",      section => 'create' }, ##
            { name => '_other_sql_settings', text => "- Other",            section => 'G'      },
        ],
        group_create_table => [
            { name => '_enable_ct_opt',          text => "- Enable options",                     section => 'create' },
            { name => '_add_ct_fields',          text => "- Add form fields",                    section => 'create' },
            { name => '_default_ai_column_name', text => "- Default auto increment column name", section => 'create' }, ##
        ],
        group_output => [
            { name => '_binary_filter',         text => "- Binary filter",              section => 'table' },
            { name => '_squash_spaces',         text => "- Squash spaces",              section => 'table' },
            { name => '_set_string',            text => "- Undef string",               section => 'table' },
            { name => '_color',                 text => "- Color",                      section => 'table' },
            { name => 'trunc_fract_first',      text => "- Trunc fract first",          section => 'table' },
            { name => '_base_indent',           text => "- Indentation SQL",            section => 'G'     },
            { name => '_pad_row_edges',         text => "- Pad row edges",              section => 'table' },
            { name => 'tab_width',              text => "- Tab width",                  section => 'table' },
            { name => '_expand_rows',           text => "- Expand table rows",          section => 'table' },
            { name => '_expanded_line_spacing', text => "- Expanded rows line spacing", section => 'table' },
            { name => 'expanded_max_width',     text => "- Expanded rows max width",    section => 'table' },
            { name => 'col_trim_threshold',     text => "- Column trim threshold",      section => 'table' },
        ],
        group_import => [
            { name => '_parse_file',        text => "- Parse tool",        section => 'insert' },
            { name => '_csv_in_char',       text => "- CSV options a",     section => 'csv_in' },
            { name => '_csv_in_options',    text => "- CSV options b",     section => 'csv_in' },
            { name => '_split_config',      text => "- Settings 'split'",  section => 'split'  },
            { name => '_input_filter',      text => "- Input filter",      section => 'insert' },
            { name => '_empty_to_null',     text => "- Empty to null",     section => 'insert' },
            { name => '_file_encoding_in',  text => "- File encoding",     section => 'insert' },
            { name => '_file_filter',       text => "- File filter",       section => 'insert' },
            { name => '_show_hidden_files', text => "- Hidden files",      section => 'insert' },
            { name => 'history_dirs',       text => "- Directory history", section => 'insert' },
            { name => '_data_source_type',  text => "- Source type",       section => 'insert' },
        ],
        group_export => [
            { name => 'export_dir',         text => "- Destination folder", section => 'export'  },
            { name => '_exported_files',    text => "- File name",          section => 'export'  },
            { name => '_csv_out_char',      text => "- CSV options a out",  section => 'csv_out' },
            { name => '_csv_out_options',   text => "- CSV options b out",  section => 'csv_out' },
            { name => '_file_encoding_out', text => "- File encoding out",  section => 'export'  },
        ],
        group_misc => [
            { name => '_search',      text => "- Search",       section => 'table' },
            { name => '_warnings',    text => "- Warnings",     section => 'G'     },
            { name => 'progress_bar', text => "- Progress bar", section => 'table' },
        ],
        group_global => [
            { name => '_menu_memory', text => "- Menu memory", section => 'G'     },
            { name => '_mouse',       text => "- Mouse mode",  section => 'table' },
        ],
        group_select_plugins => [
            { name => 'plugins', text => "- Select plugins", section => 'G' },
        ],
    };
    if ( $driver eq 'DB2' ) {
        push @{$groups->{group_output}}, { name => '_db2_encoding', text => "- DB2 encoding", section => 'G' };
    }
    return $groups->{$group};
}


my ( $no, $yes ) = ( 'NO', 'YES' );


sub group_connect {
    my ( $sf, $info, $lo, $section, $sub_group, $driver ) = @_;
    my $sub_menu_required_fields = [
        [ 'host_required', "- Host required",     [ $no, $yes ] ],
        [ 'port_required', "- Port required",     [ $no, $yes ] ],
        [ 'user_required', "- User required",     [ $no, $yes ] ],
        [ 'pass_required', "- Password required", [ $no, $yes ] ],
    ];
    my $items_login_data = [
        { name => 'host', prompt => "- Host" },
        { name => 'port', prompt => "- Port" },
        { name => 'user', prompt => "- User" },
    ];
    my $sub_menu_env_variables = [
        [ 'use_dbi_host', "- Use DBI_HOST", [ $no, $yes ] ],

lib/App/DBBrowser/Options/Menus.pm  view on Meta::CPAN

    return;
}


sub group_output {
    my ( $sf, $info, $lo, $section, $sub_group ) = @_;
    if ( $sub_group eq '_binary_filter' ) {
        my $prompt = 'How to print arbitrary binray data';
        my $sub_menu = [
            [ 'binary_filter', "- Binary filter", [ $no, 'BNRY', 'Hexadecimal' ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_squash_spaces' ) {
        my $prompt = 'Remove leading and trailing spaces and squash consecutive spaces';
        my $sub_menu = [
            [ 'squash_spaces', "- Squash spaces", [ $no, $yes ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_set_string' ) {
        my $items = [
            { name => 'undef', prompt => "Show undefined fields as" },
        ];
        my $prompt = 'Undef string';
        $sf->__group_readline( $info, $lo, $section, $items, $prompt );
    }
    elsif ( $sub_group eq '_color' ) {
        my $prompt = '"ANSI color escapes"';
        my $sub_menu = [
            [ 'color', "- ANSI color escapes", [ $no, $yes ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq 'trunc_fract_first' ) {
        my $prompt = 'If the terminal is not wide enough:';
        my $sub_menu = [
            [ 'trunc_fract_first', "- First step: truncate fraction of numbers", [ $no, $yes ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_base_indent' ) {
        my $prompt = 'Set the indentation width for SQL substatements';
        my $sub_menu = [
            [ 'base_indent', "- Indentation", [ 0, 1, 2, 3, 4 ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq 'tab_width' ) {
        my $digits = 3;
        my $prompt = 'Set the tab width ';
        $sf->__choose_a_number_wrap( $info, $lo, $section, $sub_group, $prompt, $digits, 0 );
    }
    elsif ( $sub_group eq '_pad_row_edges' ) {
        my $prompt = '"Pad row edges"';
        my $sub_menu = [
            [ 'pad_row_edges', "- Pad row edges with a space.", [ $no, $yes ] ]
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_expand_rows' ) {
        my $prompt = 'Your choice: ';
        my $sub_menu = [
            [ 'table_expand', "- Expand table rows", [ $no, $yes ] ],
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_expanded_line_spacing' ) {
        my $prompt = 'Your choice: ';
        my $sub_menu = [
            [ 'expanded_line_spacing', "- Blank line between columns when a row is expanded.", [ $no, $yes ] ],
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq 'expanded_max_width' ) {
        my $digits = 3;
        my $prompt = 'Maximum width of expanded table rows';
        $sf->__choose_a_number_wrap( $info, $lo, $section, $sub_group, $prompt, $digits, 0 );
    }
    elsif ( $sub_group eq 'col_trim_threshold' ) {
        my $digits = 3;
        my $prompt = 'Column trim threshold ';
        $sf->__choose_a_number_wrap( $info, $lo, $section, $sub_group, $prompt, $digits, 0 );
    }
    elsif ( $sub_group eq '_db2_encoding' ) {
        my $items = [
            { name => 'db2_encoding', prompt => "DB2 application code set" },
        ];
        my $prompt = 'Set the DB2 application code set';
        $sf->__group_readline( $info, $lo, $section, $items, $prompt );
    }
    else {
        die "output: unknown sub_group $sub_group";
    }
    return;
}


sub group_import {
    my ( $sf, $info, $lo, $section, $sub_group ) = @_;
    if ( $sub_group eq '_data_source_type' ) {
        my $prompt = 'Data source options';
        my $sub_menu = [
            [ 'data_source_create_table', "- Data source \"Create table\"", [ 'plain', 'file', 'menu' ], ],
            [ 'data_source_insert',       "- Data source \"Insert into\"",  [ 'plain', 'file', 'menu' ], ],
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_parse_file' ) {
        my $prompt = 'How to parse input files';
        my $sub_menu = [
            [ 'parse_mode_input_file', "- Use", [ 'Text::CSV', 'split', 'Template', 'Spreadsheet::Read' ] ],
        ];
        $sf->__settings_menu_wrap( $info, $lo, $section, $sub_menu, $prompt );
    }
    elsif ( $sub_group eq '_csv_in_char' ) {
        my $items = [
            { name => 'sep_char',    prompt => "sep_char   " },
            { name => 'quote_char',  prompt => "quote_char " },
            { name => 'escape_char', prompt => "escape_char" },
            { name => 'eol',         prompt => "eol        " },
            { name => 'comment_str', prompt => "comment_str" },
        ];
        my $prompt = 'Text::CSV_XS options a';
        $sf->__group_readline( $info, $lo, $section, $items, $prompt );
    }
    elsif ( $sub_group eq '_csv_in_options' ) {
        my $prompt = 'Text::CSV_XS options b';
        my $sub_menu = [
            [ 'allow_loose_escapes', "- allow_loose_escapes", [ $no, $yes ] ],
            [ 'allow_loose_quotes',  "- allow_loose_quotes",  [ $no, $yes ] ],
            [ 'allow_whitespace',    "- allow_whitespace",    [ $no, $yes ] ],
            [ 'blank_is_undef',      "- blank_is_undef",      [ $no, $yes ] ],
            [ 'binary',              "- binary",              [ $no, $yes ] ],
            [ 'decode_utf8',         "- decode_utf8",         [ $no, $yes ] ],
            [ 'empty_is_undef',      "- empty_is_undef",      [ $no, $yes ] ],
            [ 'skip_empty_rows',     "- skip_empty_rows",     [ $no, $yes ] ],



( run in 0.964 second using v1.01-cache-2.11-cpan-5623c5533a1 )