Skip to content

Commit 57a4083

Browse files
authored
feat(data): support wrap mode (#108)
1 parent 3901d64 commit 57a4083

File tree

11 files changed

+602
-396
lines changed

11 files changed

+602
-396
lines changed

Cargo.lock

Lines changed: 183 additions & 148 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "otree"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
edition = "2021"
55
build = "build.rs"
66
license = "MIT"
@@ -13,6 +13,7 @@ description = "A command line tool to view objects (json/yaml/toml) in TUI tree
1313
[dependencies]
1414
anyhow = "^1"
1515
clap = { version = "^4", features = ["derive"] }
16+
console = "^0"
1617
crossterm = { version = "^0", features = ["use-dev-tty"] }
1718
dirs = "^6"
1819
hcl-rs = "^0"

docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## v0.6.2
2+
3+
### Features
4+
5+
- Data block now support wrap mode, this will disable horizontal scrolling, and
6+
long text will be split to a new line. You can enable this by `--wrap` or
7+
`-w` command line option. To change the default behavior, add `data.wrap = true` in config file. (#104)
8+
19
## v0.6.1
210

311
### Features

src/cmd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ pub struct CommandArgs {
7575
#[clap(long)]
7676
pub disable_highlight: bool,
7777

78+
/// Enable wrap mode in data block.
79+
#[clap(short, long)]
80+
pub wrap: bool,
81+
7882
/// Print loaded config.
7983
#[clap(long)]
8084
pub show_config: bool,
@@ -182,6 +186,10 @@ impl CommandArgs {
182186
cfg.data.disable_highlight = true;
183187
}
184188

189+
if self.wrap {
190+
cfg.data.wrap = true;
191+
}
192+
185193
if let Some(format) = self.header_format.as_ref() {
186194
cfg.header.format.clone_from(format);
187195
}

src/config/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ pub struct Data {
120120
pub disable_highlight: bool,
121121
#[serde(default = "Config::default_max_data_size")]
122122
pub max_data_size: usize,
123+
#[serde(default = "Config::disable")]
124+
pub wrap: bool,
123125
}
124126

125127
impl Config {
@@ -321,6 +323,7 @@ impl Data {
321323
Self {
322324
disable_highlight: Config::disable(),
323325
max_data_size: Config::default_max_data_size(),
326+
wrap: Config::disable(),
324327
}
325328
}
326329
}

0 commit comments

Comments
 (0)