Repository: dundee/gdu
Pull request #174 (2022-09-18 07:28:55)

feat: configuration option for setting maximum length of the path for current item in the progress modal

coveralls: ## Pull Request Test Coverage Report for [Build 3076285128](https://coveralls.io/builds/52556583)

* **6** of **9**   **(66.67%)**  changed or added relevant lines in **3** files are covered.
* **1** unchanged line in **1** file lost coverage.
* Overall coverage decreased (**-0.1%**) to **95.797%**

---

|  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
| :-----|--------------|--------|---: |
| [tui/tui.go](https://coveralls.io/builds/52556583/source?filename=tui%2Ftui.go#L199) | 1 | 4 | 25.0%
<!-- | **Total:** | **6** | **9** | **66.67%** | -->

|  Files with Coverage Reduction | New Missed Lines | % |
| :-----|--------------|--: |
| [report/export.go](https://coveralls.io/builds/52556583/source?filename=report%2Fexport.go#L159) | 1 | 94.41% |
<!-- | **Total:** | **1** |  | -->

|  Totals | [![Coverage Status](https://coveralls.io/builds/52556583/badge)](https://coveralls.io/builds/52556583) |
| :-- | --: |
| Change from base [Build 3075924478](https://coveralls.io/builds/52556031): |  -0.1% |
| Covered Lines: | 2439 |
| Relevant Lines: | 2546 |

---
##### 💛  - [Coveralls](https://coveralls.io)

codecov[bot]: # [Codecov](https://codecov.io/gh/dundee/gdu/pull/174?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde) Report
Base: **94.54**% // Head: **94.44**% // Decreases project coverage by **`-0.10%`** :warning:
> Coverage data is based on head [(`797af30`)](https://codecov.io/gh/dundee/gdu/pull/174?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde) compared to base [(`3a5d27a`)](https://codecov.io/gh/dundee/gdu/commit/3a5d27a6a6a47e09975eb0cb3d2168b8c35c4dec?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde).
> Patch coverage: 75.00% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
- Coverage   94.54%   94.44%   -0.11%     
==========================================
  Files          28       28              
  Lines        2493     2500       +7     
==========================================
+ Hits         2357     2361       +4     
- Misses         99      102       +3     
  Partials       37       37              
```


| [Impacted Files](https://codecov.io/gh/dundee/gdu/pull/174?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde) | Coverage Δ | |
|---|---|---|
| [tui/tui.go](https://codecov.io/gh/dundee/gdu/pull/174/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde#diff-dHVpL3R1aS5nbw==) | `85.14% <33.33%> (-0.91%)` | :arrow_down: |
| [cmd/gdu/app/app.go](https://codecov.io/gh/dundee/gdu/pull/174/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde#diff-Y21kL2dkdS9hcHAvYXBwLmdv) | `91.42% <100.00%> (+0.20%)` | :arrow_up: |
| [tui/progress.go](https://codecov.io/gh/dundee/gdu/pull/174/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde#diff-dHVpL3Byb2dyZXNzLmdv) | `100.00% <100.00%> (ø)` | |
| [report/export.go](https://codecov.io/gh/dundee/gdu/pull/174/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde#diff-cmVwb3J0L2V4cG9ydC5nbw==) | `91.77% <0.00%> (-0.64%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/dundee/gdu/pull/174?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+Milde).


Patch:
diff --git a/cmd/gdu/app/app.go b/cmd/gdu/app/app.go
index eb0ea6b..f7c0c17 100644
--- a/cmd/gdu/app/app.go
+++ b/cmd/gdu/app/app.go
@@ -68,7 +68,13 @@ type Flags struct {
 
 // Style define style config
 type Style struct {
-	SelectedRow ColorStyle `yaml:"selected-row"`
+	SelectedRow   ColorStyle        `yaml:"selected-row"`
+	ProgressModal ProgressModalOpts `yaml:"progress-modal"`
+}
+
+// ProgressModalOpts defines options for progress modal
+type ProgressModalOpts struct {
+	CurrentItemNameMaxLen int `yaml:"current-item-path-max-len"`
 }
 
 // ColorStyle defines styling of some item
@@ -218,6 +224,11 @@ func (a *App) createUI() (UI, error) {
 				ui.SetSelectedBackgroundColor(tcell.GetColor(a.Flags.Style.SelectedRow.BackgroundColor))
 			})
 		}
+		if a.Flags.Style.ProgressModal.CurrentItemNameMaxLen > 0 {
+			opts = append(opts, func(ui *tui.UI) {
+				ui.SetCurrentItemNameMaxLen(a.Flags.Style.ProgressModal.CurrentItemNameMaxLen)
+			})
+		}
 
 		ui = tui.CreateUI(
 			a.TermApp,
diff --git a/tui/progress.go b/tui/progress.go
index e46e15f..d21bb75 100644
--- a/tui/progress.go
+++ b/tui/progress.go
@@ -40,7 +40,7 @@ func (ui *UI) updateProgress() {
 					color +
 					delta.String() +
 					"[white:black:-]\nCurrent item: [white:black:b]" +
-					path.ShortenPath(currentItem, 70))
+					path.ShortenPath(currentItem, ui.currentItemNameMaxLen))
 			})
 		}(progress.ItemCount, progress.TotalSize, progress.CurrentItemName)
 
diff --git a/tui/tui.go b/tui/tui.go
index 3d34f11..9cab623 100644
--- a/tui/tui.go
+++ b/tui/tui.go
@@ -75,6 +75,7 @@ type UI struct {
 	linkedItems             fs.HardLinkedItems
 	selectedTextColor       tcell.Color
 	selectedBackgroundColor tcell.Color
+	currentItemNameMaxLen   int
 }
 
 // Option is optional function customizing the bahaviour of UI
@@ -112,6 +113,7 @@ func CreateUI(
 		linkedItems:             make(fs.HardLinkedItems, 10),
 		selectedTextColor:       tview.Styles.TitleColor,
 		selectedBackgroundColor: tview.Styles.MoreContrastBackgroundColor,
+		currentItemNameMaxLen:   70,
 	}
 	for _, o := range opts {
 		o(ui)
@@ -192,6 +194,12 @@ func (ui *UI) SetSelectedBackgroundColor(color tcell.Color) {
 	ui.selectedBackgroundColor = color
 }
 
+// SetCurrentItemNameMaxLen sets the maximum length of the path of the currently processed item
+// to be shown in the progress modal
+func (ui *UI) SetCurrentItemNameMaxLen(len int) {
+	ui.currentItemNameMaxLen = len
+}
+
 // StartUILoop starts tview application
 func (ui *UI) StartUILoop() error {
 	return ui.app.Run()


Test patch:
diff --git a/cmd/gdu/app/app_test.go b/cmd/gdu/app/app_test.go
index 13524f6..799a2d9 100644
--- a/cmd/gdu/app/app_test.go
+++ b/cmd/gdu/app/app_test.go
@@ -146,6 +146,9 @@ func TestAnalyzePathWithStyle(t *testing.T) {
 					TextColor:       "black",
 					BackgroundColor: "red",
 				},
+				ProgressModal: ProgressModalOpts{
+					CurrentItemNameMaxLen: 10,
+				},
 			},
 		},
 		[]string{"test_dir"},