forked from extern/nushell
nu-table/ Add -t/theme
argument && Replace -n/start-number
with -i/index
(#11058)
ref #11054 cc: @fdncred I've not figured out how to be able to have a flag option as `table -i` :( ```nu ~/bin/nushell> [[a b, c]; [1 [2 3 3] 3] [4 5 [1 2 [1 2 3]]]] | table -e --width=80 --theme basic -i false +---+-------+-----------+ | a | b | c | +---+-------+-----------+ | 1 | +---+ | 3 | | | | 2 | | | | | +---+ | | | | | 3 | | | | | +---+ | | | | | 3 | | | | | +---+ | | +---+-------+-----------+ | 4 | 5 | +-------+ | | | | | 1 | | | | | +-------+ | | | | | 2 | | | | | +-------+ | | | | | +---+ | | | | | | | 1 | | | | | | | +---+ | | | | | | | 2 | | | | | | | +---+ | | | | | | | 3 | | | | | | | +---+ | | | | | +-------+ | +---+-------+-----------+ ``` ```nu ~/bin/nushell> [[a b, c]; [1 [2 3 3] 3] [4 5 [1 2 [1 2 3]]]] | table -e --width=80 --theme basic -i 100 +-----+---+-------------+-----------------------+ | # | a | b | c | +-----+---+-------------+-----------------------+ | 100 | 1 | +-----+---+ | 3 | | | | | 100 | 2 | | | | | | +-----+---+ | | | | | | 101 | 3 | | | | | | +-----+---+ | | | | | | 102 | 3 | | | | | | +-----+---+ | | +-----+---+-------------+-----------------------+ | 101 | 4 | 5 | +-----+-------------+ | | | | | | 100 | 1 | | | | | | +-----+-------------+ | | | | | | 101 | 2 | | | | | | +-----+-------------+ | | | | | | 102 | +-----+---+ | | | | | | | | | 100 | 1 | | | | | | | | | +-----+---+ | | | | | | | | | 101 | 2 | | | | | | | | | +-----+---+ | | | | | | | | | 102 | 3 | | | | | | | | | +-----+---+ | | | | | | +-----+-------------+ | +-----+---+-------------+-----------------------+ ```
This commit is contained in:
@ -17,9 +17,10 @@ pub fn create_nu_table_config(
|
||||
comp: &StyleComputer,
|
||||
out: &TableOutput,
|
||||
expand: bool,
|
||||
mode: TableMode,
|
||||
) -> NuTableConfig {
|
||||
NuTableConfig {
|
||||
theme: load_theme_from_config(config),
|
||||
theme: load_theme(mode),
|
||||
with_footer: with_footer(config, out.with_header, out.table.count_rows()),
|
||||
with_index: out.with_index,
|
||||
with_header: out.with_header,
|
||||
@ -173,8 +174,8 @@ fn is_cfg_trim_keep_words(config: &Config) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn load_theme_from_config(config: &Config) -> TableTheme {
|
||||
match config.table_mode {
|
||||
pub fn load_theme(mode: TableMode) -> TableTheme {
|
||||
match mode {
|
||||
TableMode::Basic => TableTheme::basic(),
|
||||
TableMode::Thin => TableTheme::thin(),
|
||||
TableMode::Light => TableTheme::light(),
|
||||
|
Reference in New Issue
Block a user