From f359213e4f0dcabdc96051fc6015e67993a8f88e Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 8 Jan 2024 15:41:02 +0000
Subject: [PATCH] chore(deps): bump github.com/pterm/pterm from 0.12.71 to
0.12.74
Bumps [github.com/pterm/pterm](https://github.com/pterm/pterm) from 0.12.71 to 0.12.74.
- [Release notes](https://github.com/pterm/pterm/releases)
- [Commits](https://github.com/pterm/pterm/compare/v0.12.71...v0.12.74)
---
updated-dependencies:
- dependency-name: github.com/pterm/pterm
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
go.mod | 2 +-
go.sum | 4 +-
vendor/github.com/pterm/pterm/CHANGELOG.md | 1305 -------------
vendor/github.com/pterm/pterm/README.md | 1620 +++++++++++------
vendor/github.com/pterm/pterm/SECURITY.md | 1 -
.../pterm/interactive_continue_printer.go | 3 +-
.../pterm/internal/cancelation_signal.go | 8 +-
.../github.com/pterm/pterm/internal/exit.go | 14 +
vendor/github.com/pterm/pterm/logger.go | 5 +-
vendor/github.com/pterm/pterm/slog_handler.go | 17 +-
vendor/modules.txt | 2 +-
11 files changed, 1102 insertions(+), 1879 deletions(-)
delete mode 100644 vendor/github.com/pterm/pterm/CHANGELOG.md
create mode 100644 vendor/github.com/pterm/pterm/internal/exit.go
diff --git a/go.mod b/go.mod
index e86035df..e7bffdfe 100644
--- a/go.mod
+++ b/go.mod
@@ -69,7 +69,7 @@ require (
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pkg/errors v0.9.1
- github.com/pterm/pterm v0.12.71
+ github.com/pterm/pterm v0.12.74
github.com/rivo/uniseg v0.4.4 // indirect
github.com/spf13/pflag v1.0.5
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
diff --git a/go.sum b/go.sum
index cce92db8..98e72f92 100644
--- a/go.sum
+++ b/go.sum
@@ -149,8 +149,8 @@ github.com/pterm/pterm v0.12.31/go.mod h1:32ZAWZVXD7ZfG0s8qqHXePte42kdz8ECtRyEej
github.com/pterm/pterm v0.12.33/go.mod h1:x+h2uL+n7CP/rel9+bImHD5lF3nM9vJj80k9ybiiTTE=
github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5bUw8T8=
github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s=
-github.com/pterm/pterm v0.12.71 h1:KcEJ98EiVCbzDkFbktJ2gMlr4pn8IzyGb9bwK6ffkuA=
-github.com/pterm/pterm v0.12.71/go.mod h1:SUAcoZjRt+yjPWlWba+/Fd8zJJ2lSXBQWf0Z0HbFiIQ=
+github.com/pterm/pterm v0.12.74 h1:fPsds9KisCyJh4NyY6bv8QJt3FLHceb5DxI6W0An9cc=
+github.com/pterm/pterm v0.12.74/go.mod h1:+M33aZWQVpmLmLbvjykyGZ4gAfeebznRo8JMbabaxQU=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
diff --git a/vendor/github.com/pterm/pterm/CHANGELOG.md b/vendor/github.com/pterm/pterm/CHANGELOG.md
deleted file mode 100644
index 2d23495e..00000000
--- a/vendor/github.com/pterm/pterm/CHANGELOG.md
+++ /dev/null
@@ -1,1305 +0,0 @@
-
-## [Unreleased]
-
-### Bug Fixes
-- buggy basic text input ([#551](https://github.com/pterm/pterm/issues/551))
-- **textinput:** fixed buggy behavior ([#550](https://github.com/pterm/pterm/issues/550))
-
-
-
-## [v0.12.64] - 2023-08-03
-### Features
-- add custom delimiters to select printers ([#545](https://github.com/pterm/pterm/issues/545))
-
-
-
-## [v0.12.63] - 2023-07-18
-### Features
-- add filter option for `select`
-
-### Bug Fixes
-- fixed area on Windows
-- **box:** fixed wrong title length calculation
-
-### Code Refactoring
-- use WithBoolean on multiselect printer
-- use WithBoolean on multiselect printer
-- use WithBoolean method on WithFilter method of select printer
-
-
-
-## [v0.12.62] - 2023-05-24
-### Bug Fixes
-- fixed not being able to add a custom graceful shutdown
-
-
-
-## [v0.12.61] - 2023-05-14
-### Bug Fixes
-- **table:** fixed table when a column contained a whitespace at the start or end
-
-
-
-## [v0.12.60] - 2023-05-11
-### Features
-- **progressbar:** various progressbar improvements
-- **progressbar:** various progressbar improvements
-- **progressbar:** various progressbar improvements
-- **rgb:** added RGBStyle
-
-### Test
-- **rgb:** added RGBStyle tests
-
-### Code Refactoring
-- **rgb:** removed 'GetValues' for 'RGBStyle'
-
-
-
-## [v0.12.59] - 2023-04-15
-### Features
-- add optional mask to InteractiveTextInputPrinter
-
-
-
-## [v0.12.58] - 2023-04-03
-### Features
-- **logger:** implemented structured logging
-- **logger:** implemented structured logging
-- **logger:** implemented structured logging
-- **logger:** added logger
-- **logger:** create logger
-- **rgb:** made it possible to use RGB colors as background
-- **rgb:** made it possible to use RGB colors as background
-- **rgb:** made it possible to use RGB colors as background
-
-### Bug Fixes
-- **rgb:** fix Fade maxValue == current not displaying the last color
-
-
-
-## [v0.12.57] - 2023-03-28
-### Code Refactoring
-- use `pterm.Print` instead of `fmt.Print` functions
-
-
-
-## [v0.12.56] - 2023-03-14
-### Bug Fixes
-- **table:** fixed panic when multiple lines contained color in a single row
-
-
-
-## [v0.12.55] - 2023-03-04
-### Features
-- **table:** multiline support for table printer
-- **table:** multiline support for table printer
-
-### Code Refactoring
-- **table:** fixed linting
-
-
-
-## [v0.12.54] - 2023-01-22
-### Bug Fixes
-- **tree:** print top node [#443](https://github.com/pterm/pterm/issues/443)
-
-
-
-## [v0.12.53] - 2023-01-05
-### Features
-- **color:** added `color.ToStyle()`
-- **color:** added `color.ToStyle()`
-- **progressbar:** added optional title to `Start` method
-
-### Bug Fixes
-- **prefix:** fixed line numbers in different print functions
-
-
-
-## [v0.12.52] - 2023-01-05
-### Features
-- **multiselect:** added theme support for checkmarks
-- **multiselect:** added theme support for checkmarks
-
-### Test
-- **multiselect:** fixed test
-
-### Code Refactoring
-- **progressbar:** make add more safe
-
-
-
-## [v0.12.51] - 2022-12-24
-### Bug Fixes
-- Make sure the confirm printer can clean up after Ctrl+C
-
-
-
-## [v0.12.50] - 2022-11-22
-### Bug Fixes
-- revert original test & add new test
-- slice bounds out of range on select printer
-
-
-
-## [v0.12.49] - 2022-10-03
-
-
-## [v0.12.48] - 2022-10-02
-### Features
-- custom select/confirm key for interactive printer
-- add flag to disable filter/search for interactive printer
-
-
-
-## [v0.12.47] - 2022-09-19
-### Features
-- adding interactive continue printer
-
-### Bug Fixes
-- typo
-- append the selected value to the prompt
-
-### Code Refactoring
-- ignore invalid custom handles
-- initiazile handles on getSuffix
-- comment format
-- address renaming PR comments
-- show full handles by default
-- use a map for the options
-
-### Reverts
-- refactor: use a map for the options
-
-
-
-## [v0.12.46] - 2022-09-05
-### Features
-- **putils:** add `CenterText` in putils
-
-### Bug Fixes
-- **textinput:** fixed overwriting the default values
-
-
-
-## [v0.12.45] - 2022-07-26
-### Bug Fixes
-- make sure the interactive printers can cleanup after Ctrl+C
-- the interactive confirm answers should match the confirm/reject text
-
-### Test
-- add tests for custom answers
-
-
-
-## [v0.12.44] - 2022-07-22
-
-
-## [v0.12.43] - 2022-07-17
-### Bug Fixes
-- **spinner:** fix line didn't clear properly
-- **table:** fixed column length calculation for Chinese strings
-
-
-
-## [v0.12.42] - 2022-06-21
-### Features
-- **input:** added text input printer
-
-
-
-## [v0.12.41] - 2022-04-12
-
-
-## [v0.12.40] - 2022-03-28
-### Features
-- added a custom writer for all printers
-
-
-
-## [v0.12.39] - 2022-03-18
-### Features
-- use fallback color in `BigTextPrinter` when `RGB` is not supported
-
-### Test
-- fix `BigTextPrinter` test
-- removed `testdata`
-- removed snapshot testing
-
-
-
-## [v0.12.38] - 2022-03-09
-### Features
-- added `NewLettersFromStringWithRGB`
-- added `NewLettersFromStringWithRGB`
-
-### Test
-- **bigtext:** fix formatting error in bigtext test
-
-
-
-## [v0.12.37] - 2022-02-17
-### Features
-- **progressbar:** Add option to set the `MaxWidth` of the progressbar
-
-### Test
-- **progressbar:** added 100% test coverage for new features
-
-### Code Refactoring
-- **putils:** Improved styling
-
-
-
-## [v0.12.36] - 2022-02-01
-### Features
-- proposal horizontal table header row and row separators fixes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators changes
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-- proposal horizontal table header row and row separators
-
-
-
-## [v0.12.35] - 2022-02-01
-### Code Refactoring
-- fix linting
-- regenerate snapshots
-
-
-
-## [v0.12.34] - 2022-01-16
-### Bug Fixes
-- **progressbar:** refresh progressbars on every PTerm print ([#302](https://github.com/pterm/pterm/issues/302))
-
-### Test
-- removed `AreaPrinter` test output
-- **table:** changed mock reader from `os.Stdin` to `outBuf`
-
-
-
-## [v0.12.33] - 2021-10-24
-### Features
-- add `PrintOnErrorf` for every `TextPrinter` ([#279](https://github.com/pterm/pterm/issues/279))
-- **coverage:** add unit test
-- **progressbar:** made updating the progressbar title easier. ([#267](https://github.com/pterm/pterm/issues/267))
-- **table:** increase test coverage
-- **table:** revamp to follow practice
-- **table:** add support for right data alignment
-
-### Bug Fixes
-- **idea:** revert unwanted config changes
-- **linter:** do linter recommendation to delete fallthrough
-
-
-
-## [v0.12.32] - 2021-10-15
-### Features
-- added `AreaPrinter.Clear()`
-
-### Bug Fixes
-- progressbar method name
-- **header:** fixed length calculation for Chinese strings
-
-### Code Refactoring
-- change bitSize size
-
-
-
-## [v0.12.31] - 2021-09-21
-### Features
-- **prefix:** added `LineNumberOffset` to `PrefixPrinter`
-
-
-
-## [v0.12.30] - 2021-08-16
-### Bug Fixes
-- **style:** resetting to previous color also resets attributes
-
-### Code Refactoring
-- adapt new testza function name
-
-
-
-## [v0.12.29] - 2021-07-19
-### Features
-- **putils:** add `PrintAverageExecutionTime`
-
-### Test
-- fix rgb error test
-- fix internal test import cycle
-- move tests into own package
-
-### Code Refactoring
-- replace `testify` with `testza`
-
-
-
-## [v0.12.28] - 2021-07-17
-### Features
-- **spinner:** add option to show a timer
-
-### Bug Fixes
-- **bar chart:** fix panic when rendering empty horizontal bar chart
-
-### Test
-- **spinner:** try to fix RawOutput text
-- **spinner:** add raw output test
-
-### Code Refactoring
-- **spinner:** better raw output logic
-- **spinner:** refactor
-
-
-
-## [v0.12.27] - 2021-07-05
-### Bug Fixes
-- **style:** fix multiline style coloring
-
-### Test
-- **style:** fix multiline style coloring
-- **style:** fix multiline style coloring
-
-
-
-## [v0.12.26] - 2021-07-01
-### Bug Fixes
-- **spinner:** Override previous text in `UpdateText`
-
-
-
-## [v0.12.25] - 2021-07-01
-### Features
-- **table:** add `Boxed` option
-
-### Test
-- add tests for boxed `TablePrinter`
-
-
-
-## [v0.12.24] - 2021-06-13
-### Features
-- **boxprinter:** replace line breaks in title with space
-- **boxprinter:** add title center position to `BoxPrinter`
-- **boxprinter:** add title & title position to `BoxPrinter`
-- **boxprinter:** add title & title position to `BoxPrinter`
-- **putils:** add `TableDataFromSeparatedValues`
-- **putils:** add `TableDataFromTSV`
-- **putils:** add `TableDataFromCSV`
-- **putils:** add function to convert TSV to `TableData`
-- **putils:** add function to convert CSV to `TableData`
-
-### Test
-- add test for putils `TableData` generation
-- **boxprinter:** add tests for title center position to `BoxPrinter`
-- **boxprinter:** add tests for title & title position
-
-### Code Refactoring
-- **boxprinter:** prefix title positions with `Title`
-- **putils:** add `rowSeparator` to `TableFromSeparatedValues`
-
-
-
-## [v0.12.23] - 2021-06-07
-### Features
-- Add util functions to create tables from slices of structs ([#217](https://github.com/pterm/pterm/issues/217))
-
-### Bug Fixes
-- **headerprinter:** don't panic if content width > terminal width
-
-### Test
-- **prefix:** `pterm.Error` default no line number shown
-
-### Code Refactoring
-- **prefix:** `pterm.Error` default no line number shown
-
-
-
-## [v0.12.22] - 2021-05-30
-### Features
-- make spinner update faster
-
-### Performance Improvements
-- improve performance of `SpinnerPrinter`
-
-
-
-## [v0.12.21] - 2021-05-30
-### Features
-- print lines above active spinners
-- **putils:** add `DownloadFileWithProgressbar`
-
-### Test
-- clear active spinners after tests complete
-
-### Code Refactoring
-- **putils:** change internal variable name
-
-
-
-## [v0.12.20] - 2021-05-29
-### Features
-- force color output by default
-
-
-
-## [v0.12.19] - 2021-05-29
-### Features
-- add `PrintOnError` for all printers and interface
-- **putils:** add `putils` package ([#206](https://github.com/pterm/pterm/issues/206))
-
-### Bug Fixes
-- **header:** fix multiline header
-
-### Test
-- add tests for all printers for `PrintOnError`
-
-### Code Refactoring
-- make `PrintOnError` return `*TextPrinter`
-- **area:** better height calculation
-
-
-
-## [v0.12.18] - 2021-05-22
-### Features
-- add `AreaPrinter`
-- **area:** add `Center` option
-- **area:** add `Fullscreen` option
-- **area:** add `GetContent` function
-- **area:** add `AreaPrinter`
-
-### Test
-- **area:** fix tests for `AreaPrinter`
-- **area:** add `AreaPrinter` tests
-
-### Code Refactoring
-- fix linting errors
-
-
-
-## [v0.12.17] - 2021-05-14
-### Bug Fixes
-- fix `pterm.Fatal.Printfln` not panicking
-- **prefix:** fix `pterm.Fatal.Printfln` not panicking and had output in debug mode
-
-### Test
-- **prefix:** add tests for `Sprintfln` and `Printfln` function when in debug mode
-
-
-
-## [v0.12.16] - 2021-05-13
-### Code Refactoring
-- **prefix:** make `PrintOnError` accept multiple inputs
-
-
-
-## [v0.12.15] - 2021-05-13
-### Features
-- add raw output mode for `BarChart`
-- add disable styling boolean option
-- **bigtext:** add raw output mode
-- **centerprinter:** add raw output mode
-- **headerprinter:** add raw output mode
-- **panelprinter:** add raw output mode
-- **paragraph:** add raw output mode
-- **prefix:** add `PrintIfError`
-- **prefix:** add raw output mode
-- **progressbar:** add raw output mode
-- **spinner:** add raw output mode
-
-### Bug Fixes
-- **prefix:** fix `PrintOnError`
-
-### Test
-- add tests with `RawOutput` enabled
-- add interface tests for `Color` and `RGB`
-- added tests for `DisableStyling` and `EnableStyling`
-
-### Code Refactoring
-- correct behaviour of Enable-/DisableStyling
-- fix variable names
-
-
-
-## [v0.12.14] - 2021-05-09
-### Features
-- **basic-text:** add `Sprintfln` and `Printfln` function
-- **boxprinter:** add `Sprintfln` and `Printfln` function
-- **centerprinter:** add `Sprintfln` and `Printfln` function
-- **color:** add `Sprintfln` and `Printfln` function
-- **header:** add `Sprintfln` and `Printfln` function
-- **paragraph:** add `Sprintfln` and `Printfln` function
-- **prefix:** add `Sprintfln` and `Printfln` function
-- **print:** add `Sprintfln` and `Printfln` function
-- **printer-interface:** add `Sprintfln` and `Printfln` to the interface
-- **rgb:** add `Sprintfln` and `Printfln` function
-- **section:** add `Sprintfln` and `Printfln` function
-
-### Bug Fixes
-- **header:** fix inline color in `Header`
-
-### Test
-- add tests for `Sprintfln` and `Printfln` function
-
-### Code Refactoring
-- refactor `Sprintfln` and `Printfln` func. for better performance
-
-### Reverts
-- ci: change color scheme for rendered examples
-
-
-
-## [v0.12.13] - 2021-04-10
-### Bug Fixes
-- **bigtext:** fix height of some characters [#180](https://github.com/pterm/pterm/issues/180)
-- **color:** make color implement `TextPrinter`
-
-### Test
-- add interface tests
-
-### Code Refactoring
-- **examples:** center the intro of `demo`
-- **examples:** add note to box printer
-
-
-
-## [v0.12.12] - 2021-03-01
-### Features
-- **prefixprinter:** Add option to show line number of caller
-
-### Code Refactoring
-- **examples:** Update `PrefixPrinter` example
-
-
-
-## [v0.12.11] - 2021-02-26
-### Code Refactoring
-- refactor print logic of `BoxPrinter`
-- refactor print logic of `CenterPrinter`
-
-
-
-## [v0.12.10] - 2021-02-26
-### Bug Fixes
-- correct `pterm.Println()` behaviour to fit to `fmt.Println()`
-
-
-
-## [v0.12.9] - 2021-02-23
-### Bug Fixes
-- correct `pterm.Println()` behaviour to fit to `fmt.Println()`
-- change terminal package import path to updated version
-
-
-
-## [v0.12.8] - 2020-12-11
-### Features
-- **boxprinter:** add `WithHorizontalString` to `BoxPrinter`
-- **boxprinter:** add `BoxPrinter`
-- **panel:** add optional border for `Panel`
-- **panelprinter:** add theme support to `PanelPrinter`
-- **theme:** add `BoxStyle` and `BoxTextStyle`
-- **theme:** add optional theme for border in `Panel`
-
-### Bug Fixes
-- revert change horizontal string change
-
-### Test
-- **boxprinter:** add test
-- **boxprinter:** test multiple lines in one box
-- **boxprinter:** add tests for `BoxPrinter`
-- **panelprinter:** add tests for adding box printer
-- **panelprinter:** add tests for optional border for `Panel`
-- **theme:** add tests for `BoxStyle` and `BoxTextStyle`
-
-### Code Refactoring
-- remove analytics
-- **boxprinter:** return theme when style is nil
-- **boxprinter:** change `DefaultBox` top and bottom padding to 0
-- **boxprinter:** fix spacing between boxes and in boxes
-- **boxprinter:** refactor code
-- **boxprinter:** change from `RenderablePrinter` to `TextPrinter`
-- **panelprinter:** add `BoxPrinter` to surround panels with a fully custom box
-- **panelprinter:** optional border for `Panel`
-
-
-
-## [v0.12.7] - 2020-11-24
-### Features
-- add values to chart
-- add horizontal `BarChartPrinter`
-- add `BarChartPrinter`
-- add `BarChartPrinter`
-- add `BarChartPrinter`
-- **theme:** add theme support to `BarChart`
-
-### Bug Fixes
-- center bars over colored labels in `BarChart`
-
-### Test
-- add tests to `BarChartPrinter`
-
-
-
-## [v0.12.6] - 2020-11-17
-### Bug Fixes
-- disabling output works as expected now ([#149](https://github.com/pterm/pterm/issues/149))
-
-
-
-## [v0.12.5] - 2020-11-17
-### Bug Fixes
-- fix `PrefixPrinter` with multiple trailing newline endings.
-
-
-
-## [v0.12.4] - 2020-11-17
-### Bug Fixes
-- fix `Printf` of `PrefixPrinter`
-
-
-
-## [v0.12.3] - 2020-11-12
-### Test
-- reduce tests
-- different test logic for rgb printing
-- add better test names for `RGB` tests
-
-
-
-## [v0.12.2] - 2020-11-05
-### Features
-- color each line separately when using multi line input
-
-### Bug Fixes
-- fix internal `GetStringMaxWidth` max width
-
-### Test
-- **basictext:** proxy print functions to DevNull
-- **progressbar:** proxy print functions to DevNull
-
-### Code Refactoring
-- use `pterm.Sprint` to print
-
-
-
-## [v0.12.1] - 2020-11-04
-### Bug Fixes
-- **panel:** Fix output when input is colored
-
-### Performance Improvements
-- **header:** calculate margin faster
-
-
-
-## [v0.12.0] - 2020-11-04
-### Features
-- **panel:** add an option to make a padding beneath `panel`
-- **panel:** add an option to make columns the same length
-
-### Bug Fixes
-- **panel:** add invalid check for `padding` in `panel`
-
-### Test
-- **bulletlist:** `BulletListItem` remove `Render` and `Srender`
-- **bulletlist:** change `BulletList` to `BulletListPrinter`
-- **panel:** add invalid check for `padding` in `panel`
-- **panel:** add test for `WithBottomPadding`
-- **panel:** add test for `WithSameColumnWidth` & multiple `panel`
-- **panel:** add test for `WithSameColumnWidth`
-- **progressbar:** change directory name `progressbar_test` to `progressbar_printer_test`
-- **progressbar:** change `Progressbar` to `ProgressbarPrinter`
-- **spinner:** change directory name `spinner_test` to `spinner_printer_test`
-- **spinner:** change `Spinner` to `SpinnerPrinter`
-- **table:** change `Table` to `TablePrinter`
-- **tree:** change `Tree` to `TreePrinter`
-
-### Code Refactoring
-- make all printer names end with `Printer` ([#134](https://github.com/pterm/pterm/issues/134))
-- **bulletlist:** remove `DefaultBulletListItem`
-- **bulletlist:** `BulletListItem` remove `Render` and `Srender`
-- **bulletlist:** `BulletListItem` is no renderable anymore
-- **bulletlist:** change `BulletList` to `BulletListPrinter`
-- **progressbar:** change `ActiveProgressbars` to `ActiveProgressbarPrinters`
-- **progressbar:** change directory name `progressbar` to `progressbar_printer`
-- **progressbar:** change `Progressbar` to `ProgressbarPrinter`
-- **spinner:** change directory name `spinner` to `spinner_printer`
-- **spinner:** change `Spinner` to `SpinnerPrinter`
-- **table:** change `Table` to `TablePrinter`
-- **tree:** change `Tree` to `TreePrinter`
-
-### BREAKING CHANGE
-
-Removed `DefaultBulletListItem`.
-
-Change names of printers which didn't end with `Printer`. Every printer name ends with `Printer` now to fit into the new naming convention.
-
-change `ActiveProgressbars` to `ActiveProgressbarPrinters`
-
-`BulletListItem` is no renderable anymore, removed `Render` and `Srender`
-
-`BulletListItem` is no renderable anymore, removed `Render` and `Srender`
-
-`BulletListItem` is no renderable anymore
-
-change `Tree` to `TreePrinter` to unify the naming scheme
-
-change `Tree` to `TreePrinter` to unify the naming scheme
-
-change `Table` to `TablePrinter` to unify the naming scheme
-
-change `Table` to `TablePrinter` to unify the naming scheme
-
-change `Spinner` to `SpinnerPrinter` to unify the naming scheme
-
-change `Spinner` to `SpinnerPrinter` to unify the naming scheme
-
-change `Progressbar` to `ProgressbarPrinter` to unify the naming scheme
-
-change `Progressbar` to `ProgressbarPrinter` to unify the naming scheme
-
-change `BulletList` to `BulletListPrinter` to unify the naming scheme
-
-change `BulletList` to `BulletListPrinter` to unify the naming scheme
-
-
-
-## [v0.11.0] - 2020-11-03
-### Features
-- add `PanelPrinter`
-
-### Bug Fixes
-- **centerprinter:** make centerprinter func return pointer
-
-### BREAKING CHANGE
-
-make centerprinter func `WithCenterEachLineSeparately` return a pointer of centerprinter
-
-
-
-## [v0.10.1] - 2020-11-02
-### Features
-- add `CenterPrinter`
-
-
-
-## [v0.10.0] - 2020-11-01
-### Features
-- make printers return errors
-- add `DisableOutput()` and `EnableOutput()` ([#108](https://github.com/pterm/pterm/issues/108))
-
-### Code Refactoring
-- ignore errors where no errors can occur
-- **theme:** change `ListTextStyle` to `BulletListTextStyle` ([#104](https://github.com/pterm/pterm/issues/104))
-- **theme:** change `ProgressbarBarStyle` to `FgCyan` ([#106](https://github.com/pterm/pterm/issues/106))
-- **theme:** change white to default color in `Theme` ([#103](https://github.com/pterm/pterm/issues/103))
-
-### BREAKING CHANGE
-
-Interface of `RenderablePrinter` and `LivePrinter` changed.
-
-The global variable `DisableOutput` was renamed to `Output`.
-
-
-
-## [v0.9.3] - 2020-10-31
-### Features
-- add a levelList converter for TreeListPrinter
-- add `TreeListPrinter` as a renderable printer
-- add `TreeListPrinter` as a renderable printer
-- **theme:** add theme support for `Tree`
-
-### Test
-- **tree:** add `Tree` tests
-
-### Code Refactoring
-- clean up `Tree`
-- **theme:** change `TreeTextStyle` to `FgDefault`
-- **tree:** add Indent to control the spacing between levels and changed docs(examples)
-- **tree:** add more spacing between levels
-- **tree:** refactor `Tree` code and write tests for `Tree`
-- **tree:** refactor `Tree` code and write tests for `Tree`
-- **tree:** refactor `Tree` code
-- **tree:** refactor `Tree` code
-- **tree:** refactor `Tree` code
-
-
-
-## [v0.9.2] - 2020-10-29
-### Features
-- add option to disable and enable colors
-
-
-
-## [v0.9.1] - 2020-10-27
-### Code Refactoring
-- make the prefix of `Info` smaller again
-
-
-
-## [v0.9.0] - 2020-10-27
-### Features
-- add `Debug` `PrefixPrinter`
-- add support for enabling and disabling debug messages
-
-### Bug Fixes
-- progressbar disappears when done and something is printed after
-
-### Test
-- add debugger tests to `PrefixPrinter`
-- add progressbar tests
-
-### Code Refactoring
-- remove `UpdateDelay` from `Progressbar`
-- change `NewList` to `NewBulletList`
-- change `NewList` to `NewBulletList`
-- deprecate `UpdateDelay` in `Progressbar`
-
-### BREAKING CHANGE
-
-Removed `UpdateDelay` from `Progressbar`. It's no longer used. The Progressbar automatically updates on every change to the current value.
-
-Changed `NewList` to `NewBulletList`.
-
-
-
-## [v0.8.1] - 2020-10-26
-### Features
-- add fade from one RGB over several RGBs to another RGB
-
-### Code Refactoring
-- refactor doc
-- refactor code
-
-
-
-## [v0.8.0] - 2020-10-24
-### Features
-- add `BigTextPrinter` ([#75](https://github.com/pterm/pterm/issues/75))
-- use level of section printer
-- add `BulletListPrinter` ([#67](https://github.com/pterm/pterm/issues/67))
-
-### Test
-- test that `%s` won't fail to print
-
-### Code Refactoring
-- make `BigTextPrinter` release ready
-- change `LineCharacter` to `BarCharacter` ([#70](https://github.com/pterm/pterm/issues/70))
-
-### BREAKING CHANGE
-
-Changed `LineCharacter` to `BarCharacter`.
-
-
-
-## [v0.7.0] - 2020-10-20
-### Features
-- **progressbar:** add RemoveWhenDone
-
-### Bug Fixes
-- make theme accept pointer styles
-- make Spinner accept pointer Style
-- make WithMessageStyle accept Style pointer
-- add nil check to SectionPrinter Style
-- section printer Style to pointer
-
-### Test
-- add tests color and style
-- add tests to root print functions
-- add tests to progressbar
-- add tests to terminal
-- add tests to theme
-- fix internal percentage test
-- add tests to Spinner
-- add tests for TablePrinter
-- special tests for special statements
-- complete PrefixPrinter tests
-- add PrefixPrinter tests
-- rename HeaderPrinter tests
-- complete HeaderPrinter tests
-- add ParagraphPrinter tests
-- add HeaderPrinter tests
-- make unit test system check different types
-- add SectionPrinter tests
-- implement test utils
-- add rgb tests
-
-### Code Refactoring
-- use log output
-- remove obsolete if
-- fit progressbar to new percentage calculation method
-- make fatal panic
-- rename parameters
-- don't show empty line when removing a progressbar
-
-
-
-## [v0.6.1] - 2020-10-20
-### Bug Fixes
-- fix RGB methods
-
-
-
-## [v0.6.0] - 2020-10-19
-### Features
-- add BasicTextPrinter
-- add theme support to section and table printer
-- add theme support to spinner
-- add theme support to headers
-- add template support for progressbars
-- add default theme
-
-### Test
-- **benchmark:** fix spinner benchmark
-
-### Code Refactoring
-- make printers accept pointers to styles
-- remove emojis to comply with cross-platform policy
-- change LivePrinter interface to pointer output
-- change TextPrinter interface to pointer output
-
-### BREAKING CHANGE
-
-All printers only accept pointers as any `Style` attribute.
-
-LivePrinter now requires to return a pointer.
-
-TextPrinter now requires to return a pointer.
-
-
-
-## [v0.5.1] - 2020-10-14
-### Features
-- add ability to disable output ([#44](https://github.com/pterm/pterm/issues/44))
-- add `Srender` to `RenderPrinter` interface
-- add csv table support ([#42](https://github.com/pterm/pterm/issues/42))
-- add HEX to RGB converter in `RGB` ([#41](https://github.com/pterm/pterm/issues/41))
-- add theme to generated animations
-- add color fade example ([#38](https://github.com/pterm/pterm/issues/38))
-- implement `TextPrinter` into `RGB`
-- implement color fade to `Progressbar` ([#37](https://github.com/pterm/pterm/issues/37))
-- add color fade function and `RBG` ([#34](https://github.com/pterm/pterm/issues/34))
-- change `Section` style
-
-### Code Refactoring
-- declare function name as `WithCSVReader`
-
-
-
-## [v0.5.0] - 2020-10-08
-### Features
-- implement `LivePrinter` in `Spinner`
-- add `BottomPadding` to `SectionPrinter`
-- add `RenderPrinter` interface
-- implement `LivePrinter` in `Progressbar`
-- add `LivePrinter` interface
-- add `TablePrinter` ([#27](https://github.com/pterm/pterm/issues/27))
-- add `ParagraphPrinter` ([#24](https://github.com/pterm/pterm/issues/24))
-
-### Test
-- add `Print` equals `Sprint` tests for `GenericPrinter`
-- add `Spinner` benchmarks
-
-### Code Refactoring
-- rename spinner_printer.go to spinner.go
-- rename `GenericPrinter` to `TextPrinter`
-
-### BREAKING CHANGE
-
-The `GenericPrinter` is now called `TextPrinter`.
-
-
-
-## [v0.4.1] - 2020-10-07
-
-
-## [v0.4.0] - 2020-10-07
-### Features
-- add `Add` to `Style`
-- add options shorthands to `SectionPrinter`
-
-### Test
-- ignore writer close errors in stdout capture
-
-### Code Refactoring
-- use `Style` instead of colors
-- refactor function parameters to fit expectation
-- rename `RemoveColors` to `RemoveColorFromString`
-
-### BREAKING CHANGE
-
-use `Style` instead of colors
-
-Refactor function parameters to fit expectation.
-Affects: `WithStyle(colors -> style)`, `WithScope(string, colors -> scope)`
-
-rename `RemoveColors` to `RemoveColorFromString`
-
-
-
-## [v0.3.2] - 2020-10-06
-### Features
-- add `SectionPrinter`
-
-### Bug Fixes
-- fix `Sprintf` function of `HeaderPrinter`
-
-### Test
-- add tests for `HeaderPrinter` and `SectionPrinter`
-
-
-
-## [v0.3.1] - 2020-10-06
-### Features
-- add `BarFiller` to `Progressbar`
-
-### Test
-- fix import cycle
-- change to inbuilt `SetDefaultOutput` option
-- add more benchmarks
-- add benchmarks
-- add tests to `GenericPrinter` and default print methods
-
-### Code Refactoring
-- set default `BarFiller` to space
-- move tests directly into `pterm` module
-
-
-
-## [v0.3.0] - 2020-10-05
-### Bug Fixes
-- fix `WithXYZ(b ...bool)` to detect booleans correctly
-
-### Code Refactoring
-- remove `Version` constant
-- change `WithXXX(b bool)` to `WithXXX(b ...bool)`
-- change `SetXXX` to `WithXXX`
-- change `Header` to `DefaultHeader`
-
-### BREAKING CHANGE
-
-remove `Version` constant
-
-rename `SetXXX` to `WithXXX`
-
-rename `Header` to `DefaultHeader`
-
-
-
-## [v0.2.4] - 2020-10-04
-### Bug Fixes
-- `Printf` works again
-
-
-
-## [v0.2.3] - 2020-10-04
-### Features
-- automatically print above `Progressbar`
-
-### Code Refactoring
-- remove goroutine from `Progressbar`
-
-
-
-## [v0.2.2] - 2020-10-04
-### Features
-- add `Fatal` printer
-
-
-
-## [v0.2.1] - 2020-10-04
-### Features
-- make progressbar configurable
-- add percentage helper
-- add `RemoveColors`
-- add `Progressbar` ([#5](https://github.com/pterm/pterm/issues/5))
-- add `Progressbar`
-- add fatal to `PrefixPrinter` ([#4](https://github.com/pterm/pterm/issues/4))
-- **progressbar:** fade percentage color according to value
-
-### Code Refactoring
-- bump version to "v0.2.1"
-
-
-
-## [v0.2.0] - 2020-09-30
-### Features
-- change style of `Description` printer
-- add color in color support
-- add `RemoveWhenDone` to `Spinner`
-- add multiline support to `PrefixPrinter`
-- add `UpdateText` to spinner
-
-### Bug Fixes
-- spinners spin evenly when multiple spinners are started
-
-### Performance Improvements
-- improve spinner performance
-
-### Code Refactoring
-- bump version to "v0.2.0"
-- change `WithXXX` to `SetXXX`
-- removed `Println` aliases
-
-### BREAKING CHANGE
-
-every `WithXXX` is renamed to `SetXXX`
-
-remove `GetFormattedMessage` from `PrefixPrinter`
-
-removed `Println` aliases
-
-
-
-## [v0.1.0] - 2020-09-28
-### Features
-- add spinners
-- shorten printer names and add builder methods to printers
-- add `Printo` to override printed text
-- add `FullWidth` to `HeaderPrinter`
-- add terminal size detection
-
-### Code Refactoring
-- bump version to "v0.1.0"
-- consistent example code for `Printo`
-- better comments for `Printo`
-- simplify `HeaderPrinter`
-
-### BREAKING CHANGE
-
-printer names changed
-
-removed `Header` and put it's content directly into `HeaderPrinter`
-
-
-
-## [v0.0.1] - 2020-09-21
-### Features
-- add aliases to default printers
-- add header example
-- integrate ci
-- add `HeaderPrinter`
-- add exported version variable
-- add example `override-default-printer`
-- change prefix text color to `LightWhite`
-
-### Bug Fixes
-- header should now work in CI
-
-### Code Refactoring
-- bump version to "v0.0.1"
-- refactor project
-- add comments to functions
-
-
-
-## v0.0.0 - 2020-09-18
-### Features
-- add changelog template
-- configs
-- initial commit
-
-
-[Unreleased]: https://github.com/pterm/pterm/compare/v0.12.64...HEAD
-[v0.12.64]: https://github.com/pterm/pterm/compare/v0.12.63...v0.12.64
-[v0.12.63]: https://github.com/pterm/pterm/compare/v0.12.62...v0.12.63
-[v0.12.62]: https://github.com/pterm/pterm/compare/v0.12.61...v0.12.62
-[v0.12.61]: https://github.com/pterm/pterm/compare/v0.12.60...v0.12.61
-[v0.12.60]: https://github.com/pterm/pterm/compare/v0.12.59...v0.12.60
-[v0.12.59]: https://github.com/pterm/pterm/compare/v0.12.58...v0.12.59
-[v0.12.58]: https://github.com/pterm/pterm/compare/v0.12.57...v0.12.58
-[v0.12.57]: https://github.com/pterm/pterm/compare/v0.12.56...v0.12.57
-[v0.12.56]: https://github.com/pterm/pterm/compare/v0.12.55...v0.12.56
-[v0.12.55]: https://github.com/pterm/pterm/compare/v0.12.54...v0.12.55
-[v0.12.54]: https://github.com/pterm/pterm/compare/v0.12.53...v0.12.54
-[v0.12.53]: https://github.com/pterm/pterm/compare/v0.12.52...v0.12.53
-[v0.12.52]: https://github.com/pterm/pterm/compare/v0.12.51...v0.12.52
-[v0.12.51]: https://github.com/pterm/pterm/compare/v0.12.50...v0.12.51
-[v0.12.50]: https://github.com/pterm/pterm/compare/v0.12.49...v0.12.50
-[v0.12.49]: https://github.com/pterm/pterm/compare/v0.12.48...v0.12.49
-[v0.12.48]: https://github.com/pterm/pterm/compare/v0.12.47...v0.12.48
-[v0.12.47]: https://github.com/pterm/pterm/compare/v0.12.46...v0.12.47
-[v0.12.46]: https://github.com/pterm/pterm/compare/v0.12.45...v0.12.46
-[v0.12.45]: https://github.com/pterm/pterm/compare/v0.12.44...v0.12.45
-[v0.12.44]: https://github.com/pterm/pterm/compare/v0.12.43...v0.12.44
-[v0.12.43]: https://github.com/pterm/pterm/compare/v0.12.42...v0.12.43
-[v0.12.42]: https://github.com/pterm/pterm/compare/v0.12.41...v0.12.42
-[v0.12.41]: https://github.com/pterm/pterm/compare/v0.12.40...v0.12.41
-[v0.12.40]: https://github.com/pterm/pterm/compare/v0.12.39...v0.12.40
-[v0.12.39]: https://github.com/pterm/pterm/compare/v0.12.38...v0.12.39
-[v0.12.38]: https://github.com/pterm/pterm/compare/v0.12.37...v0.12.38
-[v0.12.37]: https://github.com/pterm/pterm/compare/v0.12.36...v0.12.37
-[v0.12.36]: https://github.com/pterm/pterm/compare/v0.12.35...v0.12.36
-[v0.12.35]: https://github.com/pterm/pterm/compare/v0.12.34...v0.12.35
-[v0.12.34]: https://github.com/pterm/pterm/compare/v0.12.33...v0.12.34
-[v0.12.33]: https://github.com/pterm/pterm/compare/v0.12.32...v0.12.33
-[v0.12.32]: https://github.com/pterm/pterm/compare/v0.12.31...v0.12.32
-[v0.12.31]: https://github.com/pterm/pterm/compare/v0.12.30...v0.12.31
-[v0.12.30]: https://github.com/pterm/pterm/compare/v0.12.29...v0.12.30
-[v0.12.29]: https://github.com/pterm/pterm/compare/v0.12.28...v0.12.29
-[v0.12.28]: https://github.com/pterm/pterm/compare/v0.12.27...v0.12.28
-[v0.12.27]: https://github.com/pterm/pterm/compare/v0.12.26...v0.12.27
-[v0.12.26]: https://github.com/pterm/pterm/compare/v0.12.25...v0.12.26
-[v0.12.25]: https://github.com/pterm/pterm/compare/v0.12.24...v0.12.25
-[v0.12.24]: https://github.com/pterm/pterm/compare/v0.12.23...v0.12.24
-[v0.12.23]: https://github.com/pterm/pterm/compare/v0.12.22...v0.12.23
-[v0.12.22]: https://github.com/pterm/pterm/compare/v0.12.21...v0.12.22
-[v0.12.21]: https://github.com/pterm/pterm/compare/v0.12.20...v0.12.21
-[v0.12.20]: https://github.com/pterm/pterm/compare/v0.12.19...v0.12.20
-[v0.12.19]: https://github.com/pterm/pterm/compare/v0.12.18...v0.12.19
-[v0.12.18]: https://github.com/pterm/pterm/compare/v0.12.17...v0.12.18
-[v0.12.17]: https://github.com/pterm/pterm/compare/v0.12.16...v0.12.17
-[v0.12.16]: https://github.com/pterm/pterm/compare/v0.12.15...v0.12.16
-[v0.12.15]: https://github.com/pterm/pterm/compare/v0.12.14...v0.12.15
-[v0.12.14]: https://github.com/pterm/pterm/compare/v0.12.13...v0.12.14
-[v0.12.13]: https://github.com/pterm/pterm/compare/v0.12.12...v0.12.13
-[v0.12.12]: https://github.com/pterm/pterm/compare/v0.12.11...v0.12.12
-[v0.12.11]: https://github.com/pterm/pterm/compare/v0.12.10...v0.12.11
-[v0.12.10]: https://github.com/pterm/pterm/compare/v0.12.9...v0.12.10
-[v0.12.9]: https://github.com/pterm/pterm/compare/v0.12.8...v0.12.9
-[v0.12.8]: https://github.com/pterm/pterm/compare/v0.12.7...v0.12.8
-[v0.12.7]: https://github.com/pterm/pterm/compare/v0.12.6...v0.12.7
-[v0.12.6]: https://github.com/pterm/pterm/compare/v0.12.5...v0.12.6
-[v0.12.5]: https://github.com/pterm/pterm/compare/v0.12.4...v0.12.5
-[v0.12.4]: https://github.com/pterm/pterm/compare/v0.12.3...v0.12.4
-[v0.12.3]: https://github.com/pterm/pterm/compare/v0.12.2...v0.12.3
-[v0.12.2]: https://github.com/pterm/pterm/compare/v0.12.1...v0.12.2
-[v0.12.1]: https://github.com/pterm/pterm/compare/v0.12.0...v0.12.1
-[v0.12.0]: https://github.com/pterm/pterm/compare/v0.11.0...v0.12.0
-[v0.11.0]: https://github.com/pterm/pterm/compare/v0.10.1...v0.11.0
-[v0.10.1]: https://github.com/pterm/pterm/compare/v0.10.0...v0.10.1
-[v0.10.0]: https://github.com/pterm/pterm/compare/v0.9.3...v0.10.0
-[v0.9.3]: https://github.com/pterm/pterm/compare/v0.9.2...v0.9.3
-[v0.9.2]: https://github.com/pterm/pterm/compare/v0.9.1...v0.9.2
-[v0.9.1]: https://github.com/pterm/pterm/compare/v0.9.0...v0.9.1
-[v0.9.0]: https://github.com/pterm/pterm/compare/v0.8.1...v0.9.0
-[v0.8.1]: https://github.com/pterm/pterm/compare/v0.8.0...v0.8.1
-[v0.8.0]: https://github.com/pterm/pterm/compare/v0.7.0...v0.8.0
-[v0.7.0]: https://github.com/pterm/pterm/compare/v0.6.1...v0.7.0
-[v0.6.1]: https://github.com/pterm/pterm/compare/v0.6.0...v0.6.1
-[v0.6.0]: https://github.com/pterm/pterm/compare/v0.5.1...v0.6.0
-[v0.5.1]: https://github.com/pterm/pterm/compare/v0.5.0...v0.5.1
-[v0.5.0]: https://github.com/pterm/pterm/compare/v0.4.1...v0.5.0
-[v0.4.1]: https://github.com/pterm/pterm/compare/v0.4.0...v0.4.1
-[v0.4.0]: https://github.com/pterm/pterm/compare/v0.3.2...v0.4.0
-[v0.3.2]: https://github.com/pterm/pterm/compare/v0.3.1...v0.3.2
-[v0.3.1]: https://github.com/pterm/pterm/compare/v0.3.0...v0.3.1
-[v0.3.0]: https://github.com/pterm/pterm/compare/v0.2.4...v0.3.0
-[v0.2.4]: https://github.com/pterm/pterm/compare/v0.2.3...v0.2.4
-[v0.2.3]: https://github.com/pterm/pterm/compare/v0.2.2...v0.2.3
-[v0.2.2]: https://github.com/pterm/pterm/compare/v0.2.1...v0.2.2
-[v0.2.1]: https://github.com/pterm/pterm/compare/v0.2.0...v0.2.1
-[v0.2.0]: https://github.com/pterm/pterm/compare/v0.1.0...v0.2.0
-[v0.1.0]: https://github.com/pterm/pterm/compare/v0.0.1...v0.1.0
-[v0.0.1]: https://github.com/pterm/pterm/compare/v0.0.0...v0.0.1
diff --git a/vendor/github.com/pterm/pterm/README.md b/vendor/github.com/pterm/pterm/README.md
index 4ac3f28e..c7a37292 100644
--- a/vendor/github.com/pterm/pterm/README.md
+++ b/vendor/github.com/pterm/pterm/README.md
@@ -98,11 +98,11 @@ go get github.com/pterm/pterm
| Feature | Feature | Feature | Feature | Feature |
| :-------: | :-------: | :-------: | :-------: | :-------: |
| Area
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/area) |Barchart
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/barchart) |Basictext
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/basictext) |Bigtext
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/bigtext) |Box
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/box) |
-| Bulletlist
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/bulletlist) |Center
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/center) |Coloring
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/coloring) |Demo
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/demo) |Header
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/header) |
-| Heatmap
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/heatmap) |Interactive confirm
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_confirm) |Interactive continue
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_continue) |Interactive multiselect
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_multiselect) |Interactive select
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_select) |
-| Interactive textinput
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_textinput) |Logger
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/logger) |Multiple-live-printers
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/multiple-live-printers) |Panel
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/panel) |Paragraph
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/paragraph) |
-| Prefix
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/prefix) |Progressbar
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/progressbar) |Section
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/section) |Slog
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/slog) |Spinner
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/spinner) |
-| Style
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/style) |Table
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/table) |Theme
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/theme) |Tree
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/tree) | |
+| Bulletlist
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/bulletlist) |Center
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/center) |Coloring
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/coloring) |Header
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/header) |Heatmap
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/heatmap) |
+| Interactive confirm
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_confirm) |Interactive continue
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_continue) |Interactive multiselect
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_multiselect) |Interactive select
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_select) |Interactive textinput
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/interactive_textinput) |
+| Logger
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/logger) |Multiple-live-printers
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/multiple-live-printers) |Panel
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/panel) |Paragraph
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/paragraph) |Prefix
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/prefix) |
+| Progressbar
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/progressbar) |Section
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/section) |Slog
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/slog) |Spinner
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/spinner) |Style
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/style) |
+| Table
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/table) |Theme
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/theme) |Tree
[(Examples)](https://github.com/pterm/pterm/tree/master/_examples/tree) | | |
@@ -135,9 +135,9 @@ go get github.com/pterm/pterm
-### area/center
+### area/demo
-
+
@@ -150,16 +150,37 @@ import (
"time"
"github.com/pterm/pterm"
+ "github.com/pterm/pterm/putils"
)
func main() {
+ // Print an informational message using PTerm's Info printer.
+ // This message will stay in place while the area updates.
+ pterm.Info.Println("The previous text will stay in place, while the area updates.")
+
+ // Print two new lines as spacer.
+ pterm.Print("\n\n")
+
+ // Start the Area printer from PTerm's DefaultArea, with the Center option.
+ // The Area printer allows us to update a specific area of the console output.
+ // The returned 'area' object is used to control the area updates.
area, _ := pterm.DefaultArea.WithCenter().Start()
- for i := 0; i < 5; i++ {
- area.Update(pterm.Sprintf("Current count: %d\nAreas can update their content dynamically!", i))
+ // Loop 10 times to update the area with the current time.
+ for i := 0; i < 10; i++ {
+ // Get the current time, format it as "15:04:05" (hour:minute:second), and convert it to a string.
+ // Then, create a BigText from the time string using PTerm's DefaultBigText and putils NewLettersFromString.
+ // The Srender() function is used to save the BigText as a string.
+ str, _ := pterm.DefaultBigText.WithLetters(putils.LettersFromString(time.Now().Format("15:04:05"))).Srender()
+
+ // Update the Area contents with the current time string.
+ area.Update(str)
+
+ // Sleep for a second before the next update.
time.Sleep(time.Second)
}
+ // Stop the Area printer after all updates are done.
area.Stop()
}
@@ -167,9 +188,9 @@ func main() {
-### area/default
+### area/center
-
+
@@ -185,13 +206,21 @@ import (
)
func main() {
- area, _ := pterm.DefaultArea.Start()
+ // Start a new default area in the center of the terminal.
+ // The Start() function returns the created area and an error.
+ area, _ := pterm.DefaultArea.WithCenter().Start()
+ // Loop 5 times to simulate a dynamic update.
for i := 0; i < 5; i++ {
+ // Update the content of the area with the current count.
+ // The Sprintf function is used to format the string.
area.Update(pterm.Sprintf("Current count: %d\nAreas can update their content dynamically!", i))
+
+ // Pause for a second to simulate a time-consuming task.
time.Sleep(time.Second)
}
+ // Stop the area after all updates are done.
area.Stop()
}
@@ -199,9 +228,9 @@ func main() {
-### area/demo
+### area/default
-
+
@@ -217,15 +246,22 @@ import (
)
func main() {
- pterm.Info.Println("The previous text will stay in place, while the area updates.")
- pterm.Print("\n\n") // Add two new lines as spacer.
+ // Start a new default area and get a reference to it.
+ // The second return value is an error which is ignored here.
+ area, _ := pterm.DefaultArea.Start()
- area, _ := pterm.DefaultArea.WithCenter().Start() // Start the Area printer, with the Center option.
- for i := 0; i < 10; i++ {
- str, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(time.Now().Format("15:04:05"))).Srender() // Save current time in str.
- area.Update(str) // Update Area contents.
+ // Loop 5 times
+ for i := 0; i < 5; i++ {
+ // Update the content of the area dynamically.
+ // Here we're just displaying the current count.
+ area.Update(pterm.Sprintf("Current count: %d\nAreas can update their content dynamically!", i))
+
+ // Pause for a second before the next update.
time.Sleep(time.Second)
}
+
+ // Stop the area after all updates are done.
+ // This will clean up and free resources used by the area.
area.Stop()
}
@@ -251,23 +287,35 @@ import (
)
func main() {
+ // Start a new fullscreen centered area.
+ // This area will be used to display the bar chart.
area, _ := pterm.DefaultArea.WithFullscreen().WithCenter().Start()
+ // Ensure the area stops updating when we're done.
defer area.Stop()
+ // Loop to update the bar chart 10 times.
for i := 0; i < 10; i++ {
+ // Create a new bar chart with dynamic bars.
+ // The bars will change based on the current iteration.
barchart := pterm.DefaultBarChart.WithBars(dynamicBars(i))
+ // Render the bar chart to a string.
+ // This string will be used to update the area.
content, _ := barchart.Srender()
+ // Update the area with the new bar chart.
area.Update(content)
+ // Wait for half a second before the next update.
time.Sleep(500 * time.Millisecond)
}
}
+// dynamicBars generates a set of bars for the bar chart.
+// The bars will change based on the current iteration.
func dynamicBars(i int) pterm.Bars {
return pterm.Bars{
- {Label: "A", Value: 10},
- {Label: "B", Value: 20 * i},
- {Label: "C", Value: 30},
- {Label: "D", Value: 40 + i},
+ {Label: "A", Value: 10}, // A static bar.
+ {Label: "B", Value: 20 * i}, // A bar that grows with each iteration.
+ {Label: "C", Value: 30}, // Another static bar.
+ {Label: "D", Value: 40 + i}, // A bar that grows slowly with each iteration.
}
}
@@ -293,13 +341,21 @@ import (
)
func main() {
+ // Start a new fullscreen area. This will return an area instance and an error.
+ // The underscore (_) is used to ignore the error.
area, _ := pterm.DefaultArea.WithFullscreen().Start()
+ // Loop 5 times to update the area content.
for i := 0; i < 5; i++ {
+ // Update the content of the area with the current count.
+ // The Sprintf function is used to format the string.
area.Update(pterm.Sprintf("Current count: %d\nAreas can update their content dynamically!", i))
+
+ // Pause for a second before the next update.
time.Sleep(time.Second)
}
+ // Stop the area after all updates are done.
area.Stop()
}
@@ -325,13 +381,22 @@ import (
)
func main() {
+ // Initialize a new PTerm area with fullscreen and center options
+ // The Start() function returns the created area and an error (ignored here)
area, _ := pterm.DefaultArea.WithFullscreen().WithCenter().Start()
+ // Loop 5 times to demonstrate dynamic content update
for i := 0; i < 5; i++ {
+ // Update the content of the area with the current count
+ // The Sprintf function is used to format the string with the count
area.Update(pterm.Sprintf("Current count: %d\nAreas can update their content dynamically!", i))
+
+ // Pause for a second
time.Sleep(time.Second)
}
+ // Stop the area after all updates are done
+ // This will clear the area and return the terminal to its normal state
area.Stop()
}
@@ -339,9 +404,9 @@ func main() {
-### barchart/custom-height
+### barchart/demo
-
+
@@ -350,29 +415,39 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "github.com/pterm/pterm"
+)
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
- {Label: "A", Value: 10},
- {Label: "B", Value: 20},
- {Label: "C", Value: 30},
- {Label: "D", Value: 40},
- {Label: "E", Value: 50},
- {Label: "F", Value: 40},
- {Label: "G", Value: 30},
- {Label: "H", Value: 20},
- {Label: "I", Value: 10},
- }).WithHeight(5).Render()
+ // Define the bars for the chart
+ bars := []pterm.Bar{
+ {Label: "Bar 1", Value: 5},
+ {Label: "Bar 2", Value: 3},
+ {Label: "Longer Label", Value: 7},
+ }
+
+ // Print an informational message
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+
+ // Create a bar chart with the defined bars and render it
+ // The DefaultBarChart is used as a base, and the bars are added with the WithBars option
+ // The Render function is then called to display the chart
+ pterm.DefaultBarChart.WithBars(bars).Render()
+
+ // Create a horizontal bar chart with the defined bars and render it
+ // The DefaultBarChart is used as a base, the chart is made horizontal with the WithHorizontal option, and the bars are added with the WithBars option
+ // The Render function is then called to display the chart
+ pterm.DefaultBarChart.WithHorizontal().WithBars(bars).Render()
}
```
-### barchart/custom-width
+### barchart/custom-height
-
+
@@ -384,7 +459,9 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
+ // Define a slice of Bar structs. Each struct represents a bar in the chart.
+ // The Label field is the name of the bar and the Value field is the height of the bar.
+ bars := []pterm.Bar{
{Label: "A", Value: 10},
{Label: "B", Value: 20},
{Label: "C", Value: 30},
@@ -394,16 +471,22 @@ func main() {
{Label: "G", Value: 30},
{Label: "H", Value: 20},
{Label: "I", Value: 10},
- }).WithHorizontal().WithWidth(5).Render()
+ }
+
+ // Create and render a bar chart with the defined bars and a height of 5.
+ // The WithBars method is used to set the bars of the chart.
+ // The WithHeight method is used to set the height of the chart.
+ // The Render method is used to display the chart in the terminal.
+ pterm.DefaultBarChart.WithBars(bars).WithHeight(5).Render()
}
```
-### barchart/default
+### barchart/custom-width
-
+
@@ -415,7 +498,8 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
+ // Define the data for the bar chart
+ barData := []pterm.Bar{
{Label: "A", Value: 10},
{Label: "B", Value: 20},
{Label: "C", Value: 30},
@@ -425,16 +509,21 @@ func main() {
{Label: "G", Value: 30},
{Label: "H", Value: 20},
{Label: "I", Value: 10},
- }).Render()
+ }
+
+ // Create a bar chart with the defined data
+ // The chart is horizontal and has a width of 5
+ // The Render() function is called to display the chart
+ pterm.DefaultBarChart.WithBars(barData).WithHorizontal().WithWidth(5).Render()
}
```
-### barchart/demo
+### barchart/default
-
+
@@ -443,29 +532,27 @@ func main() {
```go
package main
-import (
- "github.com/pterm/pterm"
-)
+import "github.com/pterm/pterm"
func main() {
- positiveBars := pterm.Bars{
- pterm.Bar{
- Label: "Bar 1",
- Value: 5,
- },
- pterm.Bar{
- Label: "Bar 2",
- Value: 3,
- },
- pterm.Bar{
- Label: "Longer Label",
- Value: 7,
- },
+ // Define the data for the bar chart. Each bar is represented by a `pterm.Bar` struct.
+ // The `Label` field represents the label of the bar, and the `Value` field represents the value of the bar.
+ bars := []pterm.Bar{
+ {Label: "A", Value: 10},
+ {Label: "B", Value: 20},
+ {Label: "C", Value: 30},
+ {Label: "D", Value: 40},
+ {Label: "E", Value: 50},
+ {Label: "F", Value: 40},
+ {Label: "G", Value: 30},
+ {Label: "H", Value: 20},
+ {Label: "I", Value: 10},
}
- pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
- _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
- _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+ // Use the `DefaultBarChart` from the `pterm` package to create a bar chart.
+ // The `WithBars` method is used to set the bars of the chart.
+ // The `Render` method is used to display the chart.
+ pterm.DefaultBarChart.WithBars(bars).Render()
}
```
@@ -486,7 +573,8 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
+ // Define the data for the bar chart
+ bars := []pterm.Bar{
{Label: "A", Value: 10},
{Label: "B", Value: 20},
{Label: "C", Value: 30},
@@ -496,7 +584,12 @@ func main() {
{Label: "G", Value: 30},
{Label: "H", Value: 20},
{Label: "I", Value: 10},
- }).WithHorizontal().Render()
+ }
+
+ // Create a bar chart with the defined data
+ // The chart is displayed horizontally
+ // The Render() function is called to display the chart
+ pterm.DefaultBarChart.WithBars(bars).WithHorizontal().Render()
}
```
@@ -517,7 +610,8 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
+ // Define the data for the bar chart
+ barData := []pterm.Bar{
{Label: "A", Value: 10},
{Label: "B", Value: 20},
{Label: "C", Value: 30},
@@ -527,7 +621,12 @@ func main() {
{Label: "G", Value: 30},
{Label: "H", Value: 20},
{Label: "I", Value: 10},
- }).WithHorizontal().WithShowValue().Render()
+ }
+
+ // Create a bar chart with the defined data
+ // The chart is horizontal and displays the value of each bar
+ // The Render() function is called to display the chart
+ pterm.DefaultBarChart.WithBars(barData).WithHorizontal().WithShowValue().Render()
}
```
@@ -550,32 +649,29 @@ import (
)
func main() {
- mixedBars := pterm.Bars{
- pterm.Bar{
- Label: "Bar 1",
- Value: 2,
- },
- pterm.Bar{
- Label: "Bar 2",
- Value: -3,
- },
- pterm.Bar{
- Label: "Bar 3",
- Value: -2,
- },
- pterm.Bar{
- Label: "Bar 4",
- Value: 5,
- },
- pterm.Bar{
- Label: "Longer Label",
- Value: 7,
- },
+ // Define a set of bars for the chart.
+ // Each bar has a label and a value.
+ bars := []pterm.Bar{
+ {Label: "Bar 1", Value: 2},
+ {Label: "Bar 2", Value: -3},
+ {Label: "Bar 3", Value: -2},
+ {Label: "Bar 4", Value: 5},
+ {Label: "Longer Label", Value: 7},
}
+ // Print a section header.
+ // This is useful for separating different parts of the output.
pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
- _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
- _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+
+ // Create a bar chart with the defined bars.
+ // The chart will display the value of each bar.
+ // The Render() function is called to display the chart.
+ pterm.DefaultBarChart.WithBars(bars).WithShowValue().Render()
+
+ // Create a horizontal bar chart with the same bars.
+ // The chart will display the value of each bar.
+ // The Render() function is called to display the chart.
+ pterm.DefaultBarChart.WithHorizontal().WithBars(bars).WithShowValue().Render()
}
```
@@ -598,23 +694,25 @@ import (
)
func main() {
+ // Define a set of bars with negative values.
+ // Each bar is represented by a struct with a label and a value.
negativeBars := pterm.Bars{
- pterm.Bar{
- Label: "Bar 1",
- Value: -5,
- },
- pterm.Bar{
- Label: "Bar 2",
- Value: -3,
- },
- pterm.Bar{
- Label: "Longer Label",
- Value: -7,
- },
+ {Label: "Bar 1", Value: -5},
+ {Label: "Bar 2", Value: -3},
+ {Label: "Longer Label", Value: -7},
}
+ // Print an informational message to the console.
pterm.Info.Println("Chart example with negative only values (bars use 100% of chart area)")
+
+ // Create a vertical bar chart with the defined bars.
+ // The WithShowValue() option is used to display the value of each bar in the chart.
+ // The Render() method is called to draw the chart.
_ = pterm.DefaultBarChart.WithBars(negativeBars).WithShowValue().Render()
+
+ // Create a horizontal bar chart with the same bars.
+ // The WithHorizontal() option is used to orient the chart horizontally.
+ // The WithShowValue() option and Render() method are used in the same way as before.
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(negativeBars).WithShowValue().Render()
}
@@ -636,7 +734,10 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBarChart.WithBars([]pterm.Bar{
+ // Define a slice of bars for the bar chart. Each bar is represented by a struct
+ // with a Label and a Value. The Label is a string that represents the name of the bar,
+ // and the Value is an integer that represents the height of the bar.
+ bars := []pterm.Bar{
{Label: "A", Value: 10},
{Label: "B", Value: 20},
{Label: "C", Value: 30},
@@ -646,7 +747,13 @@ func main() {
{Label: "G", Value: 30},
{Label: "H", Value: 20},
{Label: "I", Value: 10},
- }).WithShowValue().Render()
+ }
+
+ // Create a bar chart with the defined bars using the DefaultBarChart object from PTerm.
+ // Chain the WithBars method to set the bars of the chart.
+ // Chain the WithShowValue method to display the value of each bar on the chart.
+ // Finally, call the Render method to display the chart.
+ pterm.DefaultBarChart.WithBars(bars).WithShowValue().Render()
}
```
@@ -667,22 +774,24 @@ package main
import "github.com/pterm/pterm"
func main() {
- // A BasicText printer is used to print text, without special formatting.
- // As it implements the TextPrinter interface, you can use it in combination with other printers.
+ // The DefaultBasicText is a basic text printer provided by PTerm.
+ // It is used to print text without any special formatting.
pterm.DefaultBasicText.Println("Default basic text printer.")
+
+ // The DefaultBasicText can be used in any context that requires a TextPrinter.
+ // Here, we're using it with the LightMagenta function to color a portion of the text.
pterm.DefaultBasicText.Println("Can be used in any" + pterm.LightMagenta(" TextPrinter ") + "context.")
- pterm.DefaultBasicText.Println("For example to resolve progressbars and spinners.")
- // If you just want to print text, you should use this instead:
- // pterm.Println("Hello, World!")
+
+ // The DefaultBasicText is also useful for resolving progress bars and spinners.
}
```
-### bigtext/colored
+### bigtext/demo
-
+
@@ -697,19 +806,33 @@ import (
)
func main() {
+ // Create a large text with the LetterStyle from the standard theme.
+ // This is useful for creating title screens.
+ pterm.DefaultBigText.WithLetters(putils.LettersFromString("PTerm")).Render()
+
+ // Create a large text with differently colored letters.
+ // Here, the first letter 'P' is colored cyan and the rest 'Term' is colored light magenta.
+ // This can be used to highlight specific parts of the text.
pterm.DefaultBigText.WithLetters(
putils.LettersFromStringWithStyle("P", pterm.FgCyan.ToStyle()),
- putils.LettersFromStringWithStyle("Term", pterm.FgLightMagenta.ToStyle())).
- Render()
+ putils.LettersFromStringWithStyle("Term", pterm.FgLightMagenta.ToStyle()),
+ ).Render()
+
+ // Create a large text with a specific RGB color.
+ // This can be used when you need a specific color that is not available in the standard colors.
+ // Here, the color is gold (RGB: 255, 215, 0).
+ pterm.DefaultBigText.WithLetters(
+ putils.LettersFromStringWithRGB("PTerm", pterm.NewRGB(255, 215, 0)),
+ ).Render()
}
```
-### bigtext/default
+### bigtext/colored
-
+
@@ -724,16 +847,21 @@ import (
)
func main() {
- pterm.DefaultBigText.WithLetters(putils.LettersFromString("PTerm")).Render()
+ // Initialize a big text display with the letters "P" and "Term"
+ // "P" is displayed in cyan and "Term" is displayed in light magenta
+ pterm.DefaultBigText.WithLetters(
+ putils.LettersFromStringWithStyle("P", pterm.FgCyan.ToStyle()),
+ putils.LettersFromStringWithStyle("Term", pterm.FgLightMagenta.ToStyle())).
+ Render() // Render the big text to the terminal
}
```
-### bigtext/demo
+### bigtext/default
-
+
@@ -748,29 +876,23 @@ import (
)
func main() {
- // Print a large text with the LetterStyle from the standard theme.
- // Useful for title screens.
- pterm.DefaultBigText.WithLetters(putils.LettersFromString("PTerm")).Render()
+ // Define the text to be rendered
+ var text = "PTerm"
- // Print a large text with differently colored letters.
- pterm.DefaultBigText.WithLetters(
- putils.LettersFromStringWithStyle("P", pterm.FgCyan.ToStyle()),
- putils.LettersFromStringWithStyle("Term", pterm.FgLightMagenta.ToStyle())).
- Render()
+ // Convert the text into a format suitable for PTerm
+ var letters = putils.LettersFromString(text)
- // LettersFromStringWithRGB can be used to create a large text with a specific RGB color.
- pterm.DefaultBigText.WithLetters(
- putils.LettersFromStringWithRGB("PTerm", pterm.NewRGB(255, 215, 0))).
- Render()
+ // Render the text using PTerm's default big text style
+ pterm.DefaultBigText.WithLetters(letters).Render()
}
```
-### box/custom-padding
+### box/demo
-
+
@@ -782,21 +904,35 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBox.
- WithRightPadding(10).
- WithLeftPadding(10).
- WithTopPadding(2).
- WithBottomPadding(2).
- Println("Hello, World!")
+ // Print an informational message.
+ pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs")
+
+ // Create three panels with text, some of them with titles.
+ // The panels are created using the DefaultBox style.
+ panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
+ panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
+ panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+
+ // Combine the panels into a layout using the DefaultPanel style.
+ // The layout is a 2D grid, with each row being an array of panels.
+ // In this case, the first row contains panel1 and panel2, and the second row contains only panel3.
+ panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
+ {{Data: panel1}, {Data: panel2}},
+ {{Data: panel3}},
+ }).Srender()
+
+ // Print the panels layout inside a box with a title.
+ // The box is created using the DefaultBox style, with the title positioned at the bottom right.
+ pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
}
```
-### box/default
+### box/custom-padding
-
+
@@ -808,16 +944,17 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultBox.Println("Hello, World!")
+ // Create a default box with custom padding options and print "Hello, World!" inside it.
+ pterm.DefaultBox.WithRightPadding(10).WithLeftPadding(10).WithTopPadding(2).WithBottomPadding(2).Println("Hello, World!")
}
```
-### box/demo
+### box/default
-
+
@@ -829,18 +966,9 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs")
-
- panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
- panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
- panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
-
- panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
- {{Data: panel1}, {Data: panel2}},
- {{Data: panel3}},
- }).Srender()
-
- pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+ // Create a default box with PTerm and print a message in it.
+ // The DefaultBox.Println method automatically starts, prints the message, and stops the box.
+ pterm.DefaultBox.Println("Hello, World!")
}
```
@@ -861,19 +989,22 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Default titled bpx
+ // Create a default box with specified padding
paddedBox := pterm.DefaultBox.WithLeftPadding(4).WithRightPadding(4).WithTopPadding(1).WithBottomPadding(1)
+ // Define a title for the box
title := pterm.LightRed("I'm a box!")
- box1 := paddedBox.WithTitle(title).Sprint("Hello, World!\n 1")
- box2 := paddedBox.WithTitle(title).WithTitleTopCenter().Sprint("Hello, World!\n 2")
- box3 := paddedBox.WithTitle(title).WithTitleTopRight().Sprint("Hello, World!\n 3")
- box4 := paddedBox.WithTitle(title).WithTitleBottomRight().Sprint("Hello, World!\n 4")
- box5 := paddedBox.WithTitle(title).WithTitleBottomCenter().Sprint("Hello, World!\n 5")
- box6 := paddedBox.WithTitle(title).WithTitleBottomLeft().Sprint("Hello, World!\n 6")
- box7 := paddedBox.WithTitle(title).WithTitleTopLeft().Sprint("Hello, World!\n 7")
+ // Create boxes with the title positioned differently and containing different content
+ box1 := paddedBox.WithTitle(title).Sprint("Hello, World!\n 1") // Title at default position (top left)
+ box2 := paddedBox.WithTitle(title).WithTitleTopCenter().Sprint("Hello, World!\n 2") // Title at top center
+ box3 := paddedBox.WithTitle(title).WithTitleTopRight().Sprint("Hello, World!\n 3") // Title at top right
+ box4 := paddedBox.WithTitle(title).WithTitleBottomRight().Sprint("Hello, World!\n 4") // Title at bottom right
+ box5 := paddedBox.WithTitle(title).WithTitleBottomCenter().Sprint("Hello, World!\n 5") // Title at bottom center
+ box6 := paddedBox.WithTitle(title).WithTitleBottomLeft().Sprint("Hello, World!\n 6") // Title at bottom left
+ box7 := paddedBox.WithTitle(title).WithTitleTopLeft().Sprint("Hello, World!\n 7") // Title at top left
+ // Render the boxes in a panel layout
pterm.DefaultPanel.WithPanels([][]pterm.Panel{
{{box1}, {box2}, {box3}},
{{box4}, {box5}, {box6}},
@@ -885,9 +1016,9 @@ func main() {
-### bulletlist/customized
+### bulletlist/demo
-
+
@@ -898,24 +1029,37 @@ package main
import (
"github.com/pterm/pterm"
+ "github.com/pterm/pterm/putils"
)
func main() {
- // Print a customized list with different styles and levels.
- pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
- {Level: 0, Text: "Blue", TextStyle: pterm.NewStyle(pterm.FgBlue), BulletStyle: pterm.NewStyle(pterm.FgRed)},
- {Level: 1, Text: "Green", TextStyle: pterm.NewStyle(pterm.FgGreen), Bullet: "-", BulletStyle: pterm.NewStyle(pterm.FgLightWhite)},
- {Level: 2, Text: "Cyan", TextStyle: pterm.NewStyle(pterm.FgCyan), Bullet: ">", BulletStyle: pterm.NewStyle(pterm.FgYellow)},
- }).Render()
+ // Define a list of bullet list items with different levels.
+ bulletListItems := []pterm.BulletListItem{
+ {Level: 0, Text: "Level 0"}, // Level 0 item
+ {Level: 1, Text: "Level 1"}, // Level 1 item
+ {Level: 2, Text: "Level 2"}, // Level 2 item
+ }
+
+ // Use the default bullet list style to render the list items.
+ pterm.DefaultBulletList.WithItems(bulletListItems).Render()
+
+ // Define a string with different levels of indentation.
+ text := `0
+ 1
+ 2
+ 3`
+
+ // Convert the indented string to a bullet list and render it.
+ putils.BulletListFromString(text, " ").Render()
}
```
-### bulletlist/demo
+### bulletlist/customized
-
+
@@ -926,23 +1070,35 @@ package main
import (
"github.com/pterm/pterm"
- "github.com/pterm/pterm/putils"
)
func main() {
- // Print a list with different levels.
- // Useful to generate lists automatically from data.
- pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
- {Level: 0, Text: "Level 0"},
- {Level: 1, Text: "Level 1"},
- {Level: 2, Text: "Level 2"},
- }).Render()
+ // Define a list of bullet list items with different styles and levels.
+ bulletListItems := []pterm.BulletListItem{
+ {
+ Level: 0, // Level 0 (top level)
+ Text: "Blue", // Text to display
+ TextStyle: pterm.NewStyle(pterm.FgBlue), // Text color
+ BulletStyle: pterm.NewStyle(pterm.FgRed), // Bullet color
+ },
+ {
+ Level: 1, // Level 1 (sub-item)
+ Text: "Green", // Text to display
+ TextStyle: pterm.NewStyle(pterm.FgGreen), // Text color
+ Bullet: "-", // Custom bullet symbol
+ BulletStyle: pterm.NewStyle(pterm.FgLightWhite), // Bullet color
+ },
+ {
+ Level: 2, // Level 2 (sub-sub-item)
+ Text: "Cyan", // Text to display
+ TextStyle: pterm.NewStyle(pterm.FgCyan), // Text color
+ Bullet: ">", // Custom bullet symbol
+ BulletStyle: pterm.NewStyle(pterm.FgYellow), // Bullet color
+ },
+ }
- // Convert a text to a list and print it.
- putils.BulletListFromString(`0
- 1
- 2
- 3`, " ").Render()
+ // Create a bullet list with the defined items and render it.
+ pterm.DefaultBulletList.WithItems(bulletListItems).Render()
}
```
@@ -960,15 +1116,22 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "github.com/pterm/pterm"
+ "github.com/pterm/pterm/putils"
+)
func main() {
- pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
+ // Print a block of text centered in the terminal
+ pterm.DefaultCenter.Println("This text is centered!\nIt centers the whole block by default.\nIn that way you can do stuff like this:")
+
+ // Generate BigLetters and store in 's'
+ s, _ := pterm.DefaultBigText.WithLetters(putils.LettersFromString("PTerm")).Srender()
- // Generate BigLetters
- s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
- pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+ // Print the BigLetters 's' centered in the terminal
+ pterm.DefaultCenter.Println(s)
+ // Print each line of the text separately centered in the terminal
pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
}
@@ -990,8 +1153,7 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print all colors
-
+ // Create a table with different foreground and background colors.
pterm.DefaultTable.WithData([][]string{
{pterm.FgBlack.Sprint("Black"), pterm.FgRed.Sprint("Red"), pterm.FgGreen.Sprint("Green"), pterm.FgYellow.Sprint("Yellow")},
{"", pterm.FgLightRed.Sprint("Light Red"), pterm.FgLightGreen.Sprint("Light Green"), pterm.FgLightYellow.Sprint("Light Yellow")},
@@ -1001,18 +1163,19 @@ func main() {
{pterm.FgLightBlue.Sprint("Light Blue"), pterm.FgLightMagenta.Sprint("Light Magenta"), pterm.FgLightCyan.Sprint("Light Cyan"), pterm.FgLightWhite.Sprint("Light White")},
{pterm.BgBlue.Sprint("Blue"), pterm.BgMagenta.Sprint("Magenta"), pterm.BgCyan.Sprint("Cyan"), pterm.BgWhite.Sprint("White")},
{pterm.BgLightBlue.Sprint("Light Blue"), pterm.BgLightMagenta.Sprint("Light Magenta"), pterm.BgLightCyan.Sprint("Light Cyan"), pterm.BgLightWhite.Sprint("Light White")},
- }).Render()
+ }).Render() // Render the table.
pterm.Println()
- // Print different colored words.
+ // Print words in different colors.
pterm.Println(pterm.Red("Hello, ") + pterm.Green("World") + pterm.Cyan("!"))
pterm.Println(pterm.Red("Even " + pterm.Cyan("nested ") + pterm.Green("colors ") + "are supported!"))
pterm.Println()
- // Or print colors as a style
+ // Create a new style with a red background, light green foreground, and bold text.
style := pterm.NewStyle(pterm.BgRed, pterm.FgLightGreen, pterm.Bold)
+ // Print text using the created style.
style.Println("This text uses a style and is bold and light green with a red background!")
}
@@ -1034,16 +1197,20 @@ package main
import "github.com/pterm/pterm"
func main() {
+ // Loop from 0 to 14
for i := 0; i < 15; i++ {
switch i {
case 5:
+ // At the 5th iteration, print a message and disable the output
pterm.Info.Println("Disabled Output!")
pterm.DisableOutput()
case 10:
+ // At the 10th iteration, enable the output and print a message
pterm.EnableOutput()
pterm.Info.Println("Enabled Output!")
}
+ // Print a progress message for each iteration
pterm.Printf("Printing something... [%d/%d]\n", i, 15)
}
}
@@ -1068,16 +1235,26 @@ import (
)
func main() {
- // Print info.
+ // Print an informational message.
pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+ // Define the start and end points for the color gradient.
+ startColor := pterm.NewRGB(0, 255, 255) // Cyan
+ endColor := pterm.NewRGB(255, 0, 255) // Magenta
+
+ // Get the terminal height to determine the gradient range.
+ terminalHeight := pterm.GetTerminalHeight()
+
+ // Loop over the range of the terminal height to create a color gradient.
+ for i := 0; i < terminalHeight-2; i++ {
+ // Calculate the fade factor for the current step in the gradient.
+ fadeFactor := float32(i) / float32(terminalHeight-2)
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ // Create a color that represents the current step in the gradient.
+ currentColor := startColor.Fade(0, 1, fadeFactor, endColor)
+
+ // Print a string with the current color.
+ currentColor.Println("Hello, World!")
}
}
@@ -1103,63 +1280,64 @@ import (
)
func main() {
- white := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients start point.
- grey := pterm.NewRGB(128, 128, 128) // This RGB value is used as the gradients start point.
- black := pterm.NewRGB(0, 0, 0) // This RGB value is used as the gradients start point.
- red := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients start point.
- purple := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients start point.
- green := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients start point.
+ // Define RGB colors
+ white := pterm.NewRGB(255, 255, 255)
+ grey := pterm.NewRGB(128, 128, 128)
+ black := pterm.NewRGB(0, 0, 0)
+ red := pterm.NewRGB(255, 0, 0)
+ purple := pterm.NewRGB(255, 0, 255)
+ green := pterm.NewRGB(0, 255, 0)
- str := "RGB colors only work in Terminals which support TrueColor."
- strs := strings.Split(str, "")
- var fadeInfo string // String which will be used to print.
- for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- fadeInfo += pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), purple), grey.Fade(0, float32(len(str)), float32(i), black)).Sprint(strs[i])
- }
+ // Define strings to be printed
+ str1 := "RGB colors only work in Terminals which support TrueColor."
+ str2 := "The background and foreground colors can be customized individually."
+ str3 := "Styles can also be applied. For example: Bold or Italic."
- pterm.Info.Println(fadeInfo)
+ // Print first string with color fading from white to purple
+ printFadedString(str1, white, purple, grey, black)
- str = "The background and foreground colors can be customized individually."
- strs = strings.Split(str, "")
- var fade2 string // String which will be used to print info.
- for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- fade2 += pterm.NewRGBStyle(black, purple.Fade(0, float32(len(str)), float32(i), red)).Sprint(strs[i])
- }
+ // Print second string with color fading from purple to red
+ printFadedString(str2, black, purple, red, red)
- pterm.Println(fade2)
+ // Print third string with color fading from white to green and style changes
+ printStyledString(str3, white, green, red, black)
+}
- str = "Styles can also be applied. For example: Bold or Italic."
- strs = strings.Split(str, "")
- var fade3 string // String which will be used to print.
+// printFadedString prints a string with color fading effect
+func printFadedString(str string, fgStart, fgEnd, bgStart, bgEnd pterm.RGB) {
+ strs := strings.Split(str, "")
+ var result string
+ for i := 0; i < len(str); i++ {
+ // Create a style with color fading effect
+ style := pterm.NewRGBStyle(fgStart.Fade(0, float32(len(str)), float32(i), fgEnd), bgStart.Fade(0, float32(len(str)), float32(i), bgEnd))
+ // Append styled letter to result string
+ result += style.Sprint(strs[i])
+ }
+ pterm.Println(result)
+}
- bold := 0
+// printStyledString prints a string with color fading and style changes
+func printStyledString(str string, fgStart, fgEnd, bgStart, bgEnd pterm.RGB) {
+ strs := strings.Split(str, "")
+ var result string
boldStr := strings.Split("Bold", "")
- italic := 0
italicStr := strings.Split("Italic", "")
-
+ bold, italic := 0, 0
for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- s := pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), green), red.Fade(0, float32(len(str)), float32(i), black))
-
- // if the next letters are "Bold", then add the style "Bold".
- // else if the next letters are "Italic", then add the style "Italic".
- if bold < len(boldStr) && i+len(boldStr) <= len(strs) {
- if strings.Join(strs[i:i+len(boldStr)-bold], "") == strings.Join(boldStr[bold:], "") {
- s = s.AddOptions(pterm.Bold)
- bold++
- }
- } else if italic < len(italicStr) && i+len(italicStr)-italic < len(strs) {
- if strings.Join(strs[i:i+len(italicStr)-italic], "") == strings.Join(italicStr[italic:], "") {
- s = s.AddOptions(pterm.Italic)
- italic++
- }
+ // Create a style with color fading effect
+ style := pterm.NewRGBStyle(fgStart.Fade(0, float32(len(str)), float32(i), fgEnd), bgStart.Fade(0, float32(len(str)), float32(i), bgEnd))
+ // Check if the next letters are "Bold" or "Italic" and add the corresponding style
+ if bold < len(boldStr) && i+len(boldStr)-bold <= len(strs) && strings.Join(strs[i:i+len(boldStr)-bold], "") == strings.Join(boldStr[bold:], "") {
+ style = style.AddOptions(pterm.Bold)
+ bold++
+ } else if italic < len(italicStr) && i+len(italicStr)-italic < len(strs) && strings.Join(strs[i:i+len(italicStr)-italic], "") == strings.Join(italicStr[italic:], "") {
+ style = style.AddOptions(pterm.Italic)
+ italic++
}
- fade3 += s.Sprint(strs[i])
+ // Append styled letter to result string
+ result += style.Sprint(strs[i])
}
-
- pterm.Println(fade3)
+ pterm.Println(result)
}
```
@@ -1184,28 +1362,36 @@ import (
)
func main() {
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
- to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
- to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
- to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+ // Define RGB values for gradient points.
+ startColor := pterm.NewRGB(0, 255, 255)
+ firstPoint := pterm.NewRGB(255, 0, 255)
+ secondPoint := pterm.NewRGB(255, 0, 0)
+ thirdPoint := pterm.NewRGB(0, 255, 0)
+ endColor := pterm.NewRGB(255, 255, 255)
+ // Define the string to be printed.
str := "RGB colors only work in Terminals which support TrueColor."
strs := strings.Split(str, "")
- var fadeInfo string // String which will be used to print info.
- // For loop over the range of the string length.
+
+ // Initialize an empty string for the faded info.
+ var fadeInfo string
+
+ // Loop over the string length to create a gradient effect.
for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ // Append each character of the string with a faded color to the info string.
+ fadeInfo += startColor.Fade(0, float32(len(str)), float32(i), firstPoint).Sprint(strs[i])
}
- // Print info.
+ // Print the info string with gradient effect.
pterm.Info.Println(fadeInfo)
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ // Get the terminal height.
+ terminalHeight := pterm.GetTerminalHeight()
+
+ // Loop over the terminal height to print "Hello, World!" with a gradient effect.
+ for i := 0; i < terminalHeight-2; i++ {
+ // Print the string with a color that fades from startColor to endColor.
+ startColor.Fade(0, float32(terminalHeight-2), float32(i), firstPoint, secondPoint, thirdPoint, endColor).Println("Hello, World!")
}
}
@@ -1227,16 +1413,13 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print default error.
+ // Print a default error message with PTerm's built-in Error style.
pterm.Error.Println("This is the default Error")
- // Customize default error.
- pterm.Error.Prefix = pterm.Prefix{
- Text: "OVERRIDE",
- Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
- }
+ // Override the default error prefix with a new text and style.
+ pterm.Error.Prefix = pterm.Prefix{Text: "OVERRIDE", Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed)}
- // Print new default error.
+ // Print the error message again, this time with the overridden prefix.
pterm.Error.Println("This is the default Error after the prefix was overridden")
}
@@ -1258,10 +1441,17 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print strings with a custom RGB color.
- // NOTICE: This only works with terminals which support TrueColor.
+ // Create a new RGB color with values 178, 44, 199.
+ // This color will be used for the text.
pterm.NewRGB(178, 44, 199).Println("This text is printed with a custom RGB!")
+
+ // Create a new RGB color with values 15, 199, 209.
+ // This color will be used for the text.
pterm.NewRGB(15, 199, 209).Println("This text is printed with a custom RGB!")
+
+ // Create a new RGB color with values 201, 144, 30.
+ // This color will be used for the background.
+ // The 'true' argument indicates that the color is for the background.
pterm.NewRGB(201, 144, 30, true).Println("This text is printed with a custom RGB background!")
}
@@ -1285,17 +1475,21 @@ import (
)
func main() {
+ // Define RGB colors for foreground and background.
foregroundRGB := pterm.RGB{R: 187, G: 80, B: 0}
backgroundRGB := pterm.RGB{R: 0, G: 50, B: 123}
- // Print string with a custom foreground and background RGB color.
- pterm.NewRGBStyle(foregroundRGB, backgroundRGB).Println("This text is not styled.")
+ // Create a new RGB style with the defined foreground and background colors.
+ rgbStyle := pterm.NewRGBStyle(foregroundRGB, backgroundRGB)
- // Print string with a custom foreground and background RGB color and style bold.
- pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Bold).Println("This text is bold.")
+ // Print a string with the custom RGB style.
+ rgbStyle.Println("This text is not styled.")
- // Print string with a custom foreground and background RGB color and style italic.
- pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Italic).Println("This text is italic.")
+ // Add the 'Bold' option to the RGB style and print a string with this style.
+ rgbStyle.AddOptions(pterm.Bold).Println("This text is bold.")
+
+ // Add the 'Italic' option to the RGB style and print a string with this style.
+ rgbStyle.AddOptions(pterm.Italic).Println("This text is italic.")
}
```
@@ -1444,7 +1638,7 @@ func main() {
pterm.DefaultCenter.WithCenterEachLineSeparately().Println(fadeInfo)
})
- showcase("Fully Customizale", 2, func() {
+ showcase("Fully Customizable", 2, func() {
for i := 0; i < 4; i++ {
pterm.Println()
}
@@ -1584,9 +1778,9 @@ func randomInt(min, max int) int {
-### header/custom
+### header/demo
-
+
@@ -1598,35 +1792,25 @@ package main
import "github.com/pterm/pterm"
func main() {
- // All available options: https://pkg.go.dev/github.com/pterm/pterm#HeaderPrinter
-
- // Build on top of DefaultHeader
- pterm.DefaultHeader. // Use DefaultHeader as base
- WithMargin(15).
- WithBackgroundStyle(pterm.NewStyle(pterm.BgCyan)).
- WithTextStyle(pterm.NewStyle(pterm.FgBlack)).
- Println("This is a custom header!")
- // Instead of printing the header you can set it to a variable.
- // You can then reuse your custom header.
+ // Print a default header.
+ // This uses the default settings of PTerm to print a header.
+ pterm.DefaultHeader.Println("This is the default header!")
- // Making a completely new HeaderPrinter
- newHeader := pterm.HeaderPrinter{
- TextStyle: pterm.NewStyle(pterm.FgBlack),
- BackgroundStyle: pterm.NewStyle(pterm.BgRed),
- Margin: 20,
- }
+ // Print a spacer line for better readability.
+ pterm.Println()
- // Print header.
- newHeader.Println("This is a custom header!")
+ // Print a full-width header.
+ // This uses the WithFullWidth() option of PTerm to print a header that spans the full width of the terminal.
+ pterm.DefaultHeader.WithFullWidth().Println("This is a full-width header.")
}
```
-### header/demo
+### header/custom
-
+
@@ -1638,19 +1822,27 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print a default header.
- pterm.DefaultHeader.Println("This is the default header!")
- pterm.Println() // spacer
- pterm.DefaultHeader.WithFullWidth().Println("This is a full-width header.")
+ // Customize the DefaultHeader with a cyan background, black text, and a margin of 15.
+ pterm.DefaultHeader.WithMargin(15).WithBackgroundStyle(pterm.NewStyle(pterm.BgCyan)).WithTextStyle(pterm.NewStyle(pterm.FgBlack)).Println("This is a custom header!")
+
+ // Define a new HeaderPrinter with a red background, black text, and a margin of 20.
+ newHeader := pterm.HeaderPrinter{
+ TextStyle: pterm.NewStyle(pterm.FgBlack),
+ BackgroundStyle: pterm.NewStyle(pterm.BgRed),
+ Margin: 20,
+ }
+
+ // Print the custom header using the new HeaderPrinter.
+ newHeader.Println("This is a custom header!")
}
```
-### heatmap/custom_colors
+### heatmap/demo
-
+
@@ -1664,6 +1856,7 @@ import (
)
func main() {
+ // Define the data for the heatmap. Each sub-array represents a row in the heatmap.
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1672,25 +1865,24 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
+ // Define the labels for the X and Y axes of the heatmap.
headerData := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
- pterm.Info.Println("The following table has no rgb (supported by every terminal), no axis data and a legend.")
- pterm.Println()
-
- table := pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithLegend(false).WithColors(pterm.BgBlue, pterm.BgRed, pterm.BgGreen, pterm.BgYellow).WithLegend()
- table.Render()
+ // Create a heatmap with the defined data and axis labels, and enable RGB colors.
+ // Then render the heatmap.
+ pterm.DefaultHeatmap.WithAxisData(headerData).WithData(data).WithEnableRGB().Render()
}
```
-### heatmap/custom_legend
+### heatmap/custom_colors
-
+
@@ -1704,6 +1896,7 @@ import (
)
func main() {
+ // Define the data for the heatmap
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1712,25 +1905,34 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
+ // Define the axis labels for the heatmap
headerData := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
- pterm.Info.Println("The following table has rgb (not supported by every terminal), axis data and a custom legend.")
+ // Print an informational message
+ pterm.Info.Println("The following table has no rgb (supported by every terminal), no axis data and a legend.")
pterm.Println()
- table := pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithEnableRGB().WithLegendLabel("custom").WithLegendOnlyColoredCells()
- table.Render()
+ // Create the heatmap with the defined data and options, and render it
+ pterm.DefaultHeatmap.
+ WithData(data).
+ WithBoxed(false).
+ WithAxisData(headerData).
+ WithLegend(false).
+ WithColors(pterm.BgBlue, pterm.BgRed, pterm.BgGreen, pterm.BgYellow).
+ WithLegend().
+ Render()
}
```
-### heatmap/custom_rgb
+### heatmap/custom_legend
-
+
@@ -1744,6 +1946,7 @@ import (
)
func main() {
+ // Define the data for the heatmap
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1752,25 +1955,35 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
+ // Define the header data for the heatmap
headerData := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
- pterm.Info.Println("The following table has rgb (not supported by every terminal), axis data and a legend.")
+ // Print an informational message
+ pterm.Info.Println("The following table has rgb (not supported by every terminal), axis data and a custom legend.")
pterm.Println()
- table2 := pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithEnableRGB().WithRGBRange(pterm.NewRGB(0, 0, 255), pterm.NewRGB(255, 0, 0), pterm.NewRGB(0, 255, 0), pterm.NewRGB(255, 255, 0))
- table2.Render()
+ // Create the heatmap with the defined data and options
+ // Options are chained in a single line for simplicity
+ pterm.DefaultHeatmap.
+ WithData(data).
+ WithBoxed(false).
+ WithAxisData(headerData).
+ WithEnableRGB().
+ WithLegendLabel("custom").
+ WithLegendOnlyColoredCells().
+ Render() // Render the heatmap
}
```
-### heatmap/demo
+### heatmap/custom_rgb
-
+
@@ -1784,6 +1997,7 @@ import (
)
func main() {
+ // Define the data for the heatmap.
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1792,13 +2006,32 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
- headerData := pterm.HeatmapAxis{
+ // Define the axis labels for the heatmap.
+ axisLabels := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
- table := pterm.DefaultHeatmap.WithAxisData(headerData).WithData(data).WithEnableRGB()
- table.Render()
+ // Print an informational message.
+ pterm.Info.Println("The following table has rgb (not supported by every terminal), axis data and a legend.")
+ pterm.Println()
+
+ // Define the color range for the heatmap.
+ rgbRange := []pterm.RGB{
+ pterm.NewRGB(0, 0, 255),
+ pterm.NewRGB(255, 0, 0),
+ pterm.NewRGB(0, 255, 0),
+ pterm.NewRGB(255, 255, 0),
+ }
+
+ // Create and render the heatmap.
+ pterm.DefaultHeatmap.
+ WithData(data).
+ WithBoxed(false).
+ WithAxisData(axisLabels).
+ WithEnableRGB().
+ WithRGBRange(rgbRange...).
+ Render()
}
```
@@ -1821,6 +2054,7 @@ import (
)
func main() {
+ // Define the data for the heatmap.
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1829,16 +2063,18 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
- headerData := pterm.HeatmapAxis{
+ // Define the axis data for the heatmap.
+ axisData := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
+ // Print an informational message.
pterm.Info.Println("The following table has rgb (not supported by every terminal), axis data and a legend.")
pterm.Println()
- table2 := pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithEnableRGB().WithLegend().WithGrid(false)
- table2.Render()
+ // Create the heatmap with the defined data and options, then render it.
+ pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(axisData).WithEnableRGB().WithLegend().WithGrid(false).Render()
}
```
@@ -1859,6 +2095,7 @@ package main
import "github.com/pterm/pterm"
func main() {
+ // Define the data for the heatmap.
data := [][]float32{
{0.9, 0.2, -0.7, 0.4, -0.5, 0.6, -0.3, 0.8, -0.1, -1.0, 0.1, -0.8, 0.3},
{0.2, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.9, -0.9, -0.7, -0.5, -0.3},
@@ -1867,16 +2104,18 @@ func main() {
{0.5, 0.6, 0.1, -0.2, -0.7, 0.8, 0.6, 0.1, -0.5, -0.7, 0.7, 0.3, 0.0},
}
+ // Define the axis labels for the heatmap.
headerData := pterm.HeatmapAxis{
XAxis: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"},
YAxis: []string{"1", "2", "3", "4", "5"},
}
+ // Print an informational message.
pterm.Info.Println("The following table has no rgb (supported by every terminal), no axis data and no legend.")
pterm.Println()
- table := pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithLegend(false)
- table.Render()
+ // Create the heatmap with the specified data and options, and render it.
+ pterm.DefaultHeatmap.WithData(data).WithBoxed(false).WithAxisData(headerData).WithLegend(false).Render()
}
```
@@ -1899,11 +2138,19 @@ import (
)
func main() {
+ // Show an interactive confirmation dialog and get the result.
result, _ := pterm.DefaultInteractiveConfirm.Show()
- pterm.Println() // Blank line
+
+ // Print a blank line for better readability.
+ pterm.Println()
+
+ // Print the user's answer in a formatted way.
pterm.Info.Printfln("You answered: %s", boolToText(result))
}
+// boolToText converts a boolean value to a colored text.
+// If the value is true, it returns a green "Yes".
+// If the value is false, it returns a red "No".
func boolToText(b bool) string {
if b {
return pterm.Green("Yes")
@@ -1931,8 +2178,21 @@ import (
)
func main() {
- result, _ := pterm.DefaultInteractiveContinue.Show()
- pterm.Println() // Blank line
+ // Create an interactive continue prompt with default settings
+ // This will pause the program execution until the user presses enter
+ // The message displayed is "Press 'Enter' to continue..."
+ prompt := pterm.DefaultInteractiveContinue
+
+ // Show the prompt and wait for user input
+ // The returned result is the user's input (should be empty as it's a continue prompt)
+ // The second return value is an error which is ignored here
+ result, _ := prompt.Show()
+
+ // Print a blank line for better readability
+ pterm.Println()
+
+ // Print the user's input with an info prefix
+ // As this is a continue prompt, the input should be empty
pterm.Info.Printfln("You answered: %s", result)
}
@@ -1940,9 +2200,9 @@ func main() {
-### interactive_multiselect/custom-checkmarks
+### interactive_multiselect/demo
-
+
@@ -1953,25 +2213,28 @@ package main
import (
"fmt"
-
- "atomicgo.dev/keyboard/keys"
-
"github.com/pterm/pterm"
)
func main() {
+ // Initialize an empty slice to hold the options.
var options []string
- for i := 0; i < 5; i++ {
+ // Populate the options slice with 100 options.
+ for i := 0; i < 100; i++ {
options = append(options, fmt.Sprintf("Option %d", i))
}
- printer := pterm.DefaultInteractiveMultiselect.WithOptions(options)
- printer.Filter = false
- printer.KeyConfirm = keys.Enter
- printer.KeySelect = keys.Space
- printer.Checkmark = &pterm.Checkmark{Checked: pterm.Green("+"), Unchecked: pterm.Red("-")}
- selectedOptions, _ := printer.Show()
+ // Add 5 more options to the slice, indicating the availability of fuzzy searching.
+ for i := 0; i < 5; i++ {
+ options = append(options, fmt.Sprintf("You can use fuzzy searching (%d)", i))
+ }
+
+ // Use PTerm's interactive multiselect to present the options to the user and capture their selections.
+ // The Show() method displays the options and waits for user input.
+ selectedOptions, _ := pterm.DefaultInteractiveMultiselect.WithOptions(options).Show()
+
+ // Print the selected options, highlighted in green.
pterm.Info.Printfln("Selected options: %s", pterm.Green(selectedOptions))
}
@@ -1979,9 +2242,9 @@ func main() {
-### interactive_multiselect/custom-keys
+### interactive_multiselect/custom-checkmarks
-
+
@@ -1992,23 +2255,29 @@ package main
import (
"fmt"
-
- "atomicgo.dev/keyboard/keys"
"github.com/pterm/pterm"
)
func main() {
+ // Initialize an empty slice to hold the options
var options []string
+ // Populate the options slice with 5 options
for i := 0; i < 5; i++ {
options = append(options, fmt.Sprintf("Option %d", i))
}
- printer := pterm.DefaultInteractiveMultiselect.WithOptions(options)
- printer.Filter = false
- printer.KeyConfirm = keys.Enter
- printer.KeySelect = keys.Space
+ // Create a new interactive multiselect printer with the options
+ // Disable the filter and define the checkmark symbols
+ printer := pterm.DefaultInteractiveMultiselect.
+ WithOptions(options).
+ WithFilter(false).
+ WithCheckmark(&pterm.Checkmark{Checked: pterm.Green("+"), Unchecked: pterm.Red("-")})
+
+ // Show the interactive multiselect and get the selected options
selectedOptions, _ := printer.Show()
+
+ // Print the selected options
pterm.Info.Printfln("Selected options: %s", pterm.Green(selectedOptions))
}
@@ -2016,9 +2285,9 @@ func main() {
-### interactive_multiselect/demo
+### interactive_multiselect/custom-keys
-
+
@@ -2028,23 +2297,32 @@ func main() {
package main
import (
+ "atomicgo.dev/keyboard/keys"
"fmt"
-
"github.com/pterm/pterm"
)
func main() {
+ // Initialize an empty slice to hold the options
var options []string
- for i := 0; i < 100; i++ {
+ // Populate the options slice with 5 options
+ for i := 0; i < 5; i++ {
options = append(options, fmt.Sprintf("Option %d", i))
}
- for i := 0; i < 5; i++ {
- options = append(options, fmt.Sprintf("You can use fuzzy searching (%d)", i))
- }
+ // Create a new interactive multiselect printer with the options
+ // Disable the filter and set the keys for confirming and selecting options
+ printer := pterm.DefaultInteractiveMultiselect.
+ WithOptions(options).
+ WithFilter(false).
+ WithKeyConfirm(keys.Enter).
+ WithKeySelect(keys.Space)
- selectedOptions, _ := pterm.DefaultInteractiveMultiselect.WithOptions(options).Show()
+ // Show the interactive multiselect and get the selected options
+ selectedOptions, _ := printer.Show()
+
+ // Print the selected options
pterm.Info.Printfln("Selected options: %s", pterm.Green(selectedOptions))
}
@@ -2065,22 +2343,28 @@ package main
import (
"fmt"
-
"github.com/pterm/pterm"
)
func main() {
+ // Initialize an empty slice to hold the options
var options []string
+ // Generate 100 options and add them to the options slice
for i := 0; i < 100; i++ {
options = append(options, fmt.Sprintf("Option %d", i))
}
+ // Generate 5 additional options with a specific message and add them to the options slice
for i := 0; i < 5; i++ {
options = append(options, fmt.Sprintf("You can use fuzzy searching (%d)", i))
}
+ // Use PTerm's interactive select feature to present the options to the user and capture their selection
+ // The Show() method displays the options and waits for the user's input
selectedOption, _ := pterm.DefaultInteractiveSelect.WithOptions(options).Show()
+
+ // Display the selected option to the user with a green color for emphasis
pterm.Info.Printfln("Selected option: %s", pterm.Green(selectedOption))
}
@@ -2104,8 +2388,16 @@ import (
)
func main() {
- result, _ := pterm.DefaultInteractiveTextInput.WithMultiLine(false).Show()
- pterm.Println() // Blank line
+ // Create an interactive text input with single line input mode
+ textInput := pterm.DefaultInteractiveTextInput.WithMultiLine(false)
+
+ // Show the text input and get the result
+ result, _ := textInput.Show()
+
+ // Print a blank line for better readability
+ pterm.Println()
+
+ // Print the user's answer with an info prefix
pterm.Info.Printfln("You answered: %s", result)
}
@@ -2129,8 +2421,19 @@ import (
)
func main() {
- result, _ := pterm.DefaultInteractiveTextInput.WithMultiLine().Show() // Text input with multi line enabled
- pterm.Println() // Blank line
+ // Create a default interactive text input with multi-line enabled.
+ // This allows the user to input multiple lines of text.
+ textInput := pterm.DefaultInteractiveTextInput.WithMultiLine()
+
+ // Show the text input to the user and store the result.
+ // The second return value (an error) is ignored with '_'.
+ result, _ := textInput.Show()
+
+ // Print a blank line for better readability in the output.
+ pterm.Println()
+
+ // Print the user's input prefixed with an informational message.
+ // The '%s' placeholder is replaced with the user's input.
pterm.Info.Printfln("You answered: %s", result)
}
@@ -2152,9 +2455,17 @@ package main
import "github.com/pterm/pterm"
func main() {
- result, _ := pterm.DefaultInteractiveTextInput.WithMask("*").Show("Enter your password")
+ // Create an interactive text input with a mask for password input
+ passwordInput := pterm.DefaultInteractiveTextInput.WithMask("*")
+ // Show the password input prompt and store the result
+ result, _ := passwordInput.Show("Enter your password")
+
+ // Get the default logger from PTerm
logger := pterm.DefaultLogger
+
+ // Log the received password (masked)
+ // Note: In a real-world application, you should never log passwords
logger.Info("Password received", logger.Args("password", result))
}
@@ -2162,9 +2473,9 @@ func main() {
-### logger/custom-key-styles
+### logger/demo
-
+
@@ -2173,33 +2484,74 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "github.com/pterm/pterm"
+ "time"
+)
func main() {
- logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace) // Only show logs with a level of Trace or higher.
+ // Create a logger with trace level
+ logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace)
- // Overwrite all key styles with a new map
- logger = logger.WithKeyStyles(map[string]pterm.Style{
- "priority": *pterm.NewStyle(pterm.FgRed),
- })
+ // Log a trace level message
+ logger.Trace("Doing not so important stuff", logger.Args("priority", "super low"))
- // The priority key should now be red
- logger.Info("The priority key should now be red", logger.Args("priority", "low", "foo", "bar"))
+ // Pause for 3 seconds
+ sleep()
+
+ // Define a map with interesting stuff
+ interstingStuff := map[string]any{
+ "when were crayons invented": "1903",
+ "what is the meaning of life": 42,
+ "is this interesting": true,
+ }
- // Append a key style to the exisiting ones
- logger.AppendKeyStyle("foo", *pterm.NewStyle(pterm.FgBlue))
+ // Log a debug level message with arguments from the map
+ logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff))
- // The foo key should now be blue
- logger.Info("The foo key should now be blue", logger.Args("priority", "low", "foo", "bar"))
+ // Pause for 3 seconds
+ sleep()
+
+ // Log an info level message
+ logger.Info("That was actually interesting", logger.Args("such", "wow"))
+
+ // Pause for 3 seconds
+ sleep()
+
+ // Log a warning level message
+ logger.Warn("Oh no, I see an error coming to us!", logger.Args("speed", 88, "measures", "mph"))
+
+ // Pause for 3 seconds
+ sleep()
+
+ // Log an error level message
+ logger.Error("Damn, here it is!", logger.Args("error", "something went wrong"))
+
+ // Pause for 3 seconds
+ sleep()
+
+ // Log an info level message with a long text that will be automatically wrapped
+ logger.Info("But what's really cool is, that you can print very long logs, and PTerm will automatically wrap them for you! Say goodbye to text, that has weird line breaks!", logger.Args("very", "long"))
+
+ // Pause for 3 seconds
+ sleep()
+
+ // Log a fatal level message
+ logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true))
+}
+
+// Function to pause the execution for 3 seconds
+func sleep() {
+ time.Sleep(time.Second * 3)
}
```
-### logger/default
+### logger/custom-key-styles
-
+
@@ -2208,39 +2560,40 @@ func main() {
```go
package main
-import (
- "github.com/pterm/pterm"
- "time"
-)
+import "github.com/pterm/pterm"
func main() {
- logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace) // Only show logs with a level of Trace or higher.
-
- logger.Trace("Doing not so important stuff", logger.Args("priority", "super low"))
+ // Create a logger with a level of Trace or higher.
+ logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace)
- // You can also use the `ArgsFromMap` function to create a `Args` object from a map.
- interstingStuff := map[string]any{
- "when were crayons invented": "1903",
- "what is the meaning of life": 42,
- "is this interesting": true,
+ // Define a new style for the "priority" key.
+ priorityStyle := map[string]pterm.Style{
+ "priority": *pterm.NewStyle(pterm.FgRed),
}
- logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff))
- logger.Info("That was actually interesting", logger.Args("such", "wow"))
- logger.Warn("Oh no, I see an error coming to us!", logger.Args("speed", 88, "measures", "mph"))
- logger.Error("Damn, here it is!", logger.Args("error", "something went wrong"))
- logger.Info("But what's really cool is, that you can print very long logs, and PTerm will automatically wrap them for you! Say goodbye to text, that has weird line breaks!", logger.Args("very", "long"))
- time.Sleep(time.Second * 2)
- logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true))
+ // Overwrite all key styles with the new map.
+ logger = logger.WithKeyStyles(priorityStyle)
+
+ // Log an info message. The "priority" key will be displayed in red.
+ logger.Info("The priority key should now be red", logger.Args("priority", "low", "foo", "bar"))
+
+ // Define a new style for the "foo" key.
+ fooStyle := *pterm.NewStyle(pterm.FgBlue)
+
+ // Append the new style to the existing ones.
+ logger.AppendKeyStyle("foo", fooStyle)
+
+ // Log another info message. The "foo" key will be displayed in blue.
+ logger.Info("The foo key should now be blue", logger.Args("priority", "low", "foo", "bar"))
}
```
-### logger/demo
+### logger/default
-
+
@@ -2255,34 +2608,39 @@ import (
)
func main() {
- logger := pterm.DefaultLogger.
- WithLevel(pterm.LogLevelTrace)
+ // Create a logger with a level of Trace or higher.
+ logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace)
+ // Log a trace message with additional arguments.
logger.Trace("Doing not so important stuff", logger.Args("priority", "super low"))
- sleep()
-
+ // Create a map of interesting stuff.
interstingStuff := map[string]any{
"when were crayons invented": "1903",
"what is the meaning of life": 42,
"is this interesting": true,
}
+
+ // Log a debug message with arguments from a map.
logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff))
- sleep()
+ // Log an info message with additional arguments.
logger.Info("That was actually interesting", logger.Args("such", "wow"))
- sleep()
+
+ // Log a warning message with additional arguments.
logger.Warn("Oh no, I see an error coming to us!", logger.Args("speed", 88, "measures", "mph"))
- sleep()
+
+ // Log an error message with additional arguments.
logger.Error("Damn, here it is!", logger.Args("error", "something went wrong"))
- sleep()
+
+ // Log an info message with additional arguments. PTerm will automatically wrap long logs.
logger.Info("But what's really cool is, that you can print very long logs, and PTerm will automatically wrap them for you! Say goodbye to text, that has weird line breaks!", logger.Args("very", "long"))
- sleep()
- logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true))
-}
-func sleep() {
- time.Sleep(time.Second * 3)
+ // Pause for 2 seconds.
+ time.Sleep(time.Second * 2)
+
+ // Log a fatal message with additional arguments. This will terminate the process.
+ logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true))
}
```
@@ -2303,20 +2661,23 @@ package main
import "github.com/pterm/pterm"
func main() {
- logger := pterm.DefaultLogger.
- WithLevel(pterm.LogLevelTrace). // Only show logs with a level of Trace or higher.
- WithFormatter(pterm.LogFormatterJSON) // ! Make the logger print JSON logs.
+ // Create a logger with Trace level and JSON formatter
+ logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace).WithFormatter(pterm.LogFormatterJSON)
+ // Log a Trace level message with additional arguments
logger.Trace("Doing not so important stuff", logger.Args("priority", "super low"))
- // You can also use the `ArgsFromMap` function to create a `Args` object from a map.
- interstingStuff := map[string]any{
+ // Create a map of interesting stuff
+ interestingStuff := map[string]any{
"when were crayons invented": "1903",
"what is the meaning of life": 42,
"is this interesting": true,
}
- logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff))
+ // Log a Debug level message with arguments from the map
+ logger.Debug("This might be interesting", logger.ArgsFromMap(interestingStuff))
+
+ // Log Info, Warn, Error, and Fatal level messages with additional arguments
logger.Info("That was actually interesting", logger.Args("such", "wow"))
logger.Warn("Oh no, I see an error coming to us!", logger.Args("speed", 88, "measures", "mph"))
logger.Error("Damn, here it is!", logger.Args("error", "something went wrong"))
@@ -2342,24 +2703,35 @@ package main
import "github.com/pterm/pterm"
func main() {
- logger := pterm.DefaultLogger.
- WithLevel(pterm.LogLevelTrace). // Only show logs with a level of Trace or higher.
- WithCaller() // ! Show the caller of the log function.
+ // Create a logger with Trace level and caller information
+ logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace).WithCaller()
+ // Log a trace message with additional arguments
logger.Trace("Doing not so important stuff", logger.Args("priority", "super low"))
- // You can also use the `ArgsFromMap` function to create a `Args` object from a map.
- interstingStuff := map[string]any{
+ // Create a map of interesting stuff
+ interestingStuff := map[string]any{
"when were crayons invented": "1903",
"what is the meaning of life": 42,
"is this interesting": true,
}
- logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff))
+ // Log a debug message with arguments from a map
+ logger.Debug("This might be interesting", logger.ArgsFromMap(interestingStuff))
+
+ // Log an info message with additional arguments
logger.Info("That was actually interesting", logger.Args("such", "wow"))
+
+ // Log a warning message with additional arguments
logger.Warn("Oh no, I see an error coming to us!", logger.Args("speed", 88, "measures", "mph"))
+
+ // Log an error message with additional arguments
logger.Error("Damn, here it is!", logger.Args("error", "something went wrong"))
+
+ // Log an info message with additional arguments. PTerm will automatically wrap long logs.
logger.Info("But what's really cool is, that you can print very long logs, and PTerm will automatically wrap them for you! Say goodbye to text, that has weird line breaks!", logger.Args("very", "long"))
+
+ // Log a fatal message with additional arguments. This will terminate the process.
logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true))
}
@@ -2379,54 +2751,61 @@ func main() {
package main
import (
- "github.com/pterm/pterm"
"time"
+
+ "github.com/pterm/pterm"
)
func main() {
+ // Create a multi printer for managing multiple printers
multi := pterm.DefaultMultiPrinter
+ // Create two spinners with their own writers
spinner1, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Spinner 1")
spinner2, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Spinner 2")
+
+ // Create five progress bars with their own writers and a total of 100
pb1, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 1")
pb2, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 2")
pb3, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 3")
pb4, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 4")
pb5, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 5")
+ // Start the multi printer
multi.Start()
- // Randomly increment progress bars for demo purposes.
+ // Increment progress bars and spinners based on certain conditions
for i := 1; i <= 100; i++ {
- pb1.Increment()
+ pb1.Increment() // Increment progress bar 1 every iteration
if i%2 == 0 {
- pb2.Add(3)
+ pb2.Add(3) // Add 3 to progress bar 2 every even iteration
}
if i%5 == 0 {
- pb3.Increment()
+ pb3.Increment() // Increment progress bar 3 every 5th iteration
}
if i%10 == 0 {
- pb4.Increment()
+ pb4.Increment() // Increment progress bar 4 every 10th iteration
}
if i%3 == 0 {
- pb5.Increment()
+ pb5.Increment() // Increment progress bar 5 every 3rd iteration
}
if i%50 == 0 {
- spinner1.Success("Spinner 1 is done!")
+ spinner1.Success("Spinner 1 is done!") // Mark spinner 1 as successful every 50th iteration
}
if i%60 == 0 {
- spinner2.Fail("Spinner 2 failed!")
+ spinner2.Fail("Spinner 2 failed!") // Mark spinner 2 as failed every 60th iteration
}
- time.Sleep(time.Millisecond * 50)
+ time.Sleep(time.Millisecond * 50) // Sleep for 50 milliseconds between each iteration
}
+ // Stop the multi printer
multi.Stop()
}
@@ -2448,13 +2827,20 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Declare panels in a two dimensional grid system.
+ // Define panels in a 2D grid system
panels := pterm.Panels{
- {{Data: "This is the first panel"}, {Data: pterm.DefaultHeader.Sprint("Hello, World!")}, {Data: "This\npanel\ncontains\nmultiple\nlines"}},
- {{Data: pterm.Red("This is another\npanel line")}, {Data: "This is the second panel\nwith a new line"}},
+ {
+ {Data: "This is the first panel"},
+ {Data: pterm.DefaultHeader.Sprint("Hello, World!")},
+ {Data: "This\npanel\ncontains\nmultiple\nlines"},
+ },
+ {
+ {Data: pterm.Red("This is another\npanel line")},
+ {Data: "This is the second panel\nwith a new line"},
+ },
}
- // Print panels.
+ // Render the panels with a padding of 5
_ = pterm.DefaultPanel.WithPanels(panels).WithPadding(5).Render()
}
@@ -2462,9 +2848,9 @@ func main() {
-### paragraph/customized
+### paragraph/demo
-
+
@@ -2476,15 +2862,18 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print a paragraph with a custom maximal width.
- pterm.DefaultParagraph.WithMaxWidth(60).Println("This is a custom paragraph printer. As you can see, no words are separated, " +
+ // Using the default paragraph printer to print a long text.
+ // The text is split at the spaces, which is useful for continuous text of all kinds.
+ // The line width can be manually adjusted if needed.
+ pterm.DefaultParagraph.Println("This is the default paragraph printer. As you can see, no words are separated, " +
"but the text is split at the spaces. This is useful for continuous text of all kinds. You can manually change the line width if you want to." +
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
- // Print one line space.
+ // Printing a line space for separation.
pterm.Println()
- // Print text without a paragraph printer.
+ // Printing a long text without using the paragraph printer.
+ // The default Println() function is used here, which does not provide intelligent splitting.
pterm.Println("This text is written with the default Println() function. No intelligent splitting here." +
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
}
@@ -2493,9 +2882,9 @@ func main() {
-### paragraph/demo
+### paragraph/customized
-
+
@@ -2507,17 +2896,23 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print long text with default paragraph printer.
- pterm.DefaultParagraph.Println("This is the default paragraph printer. As you can see, no words are separated, " +
+ // Define a long text to be printed as a paragraph.
+ longText := "This is a custom paragraph printer. As you can see, no words are separated, " +
"but the text is split at the spaces. This is useful for continuous text of all kinds. You can manually change the line width if you want to." +
- "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam"
- // Print one line space.
+ // Print the long text as a paragraph with a custom maximal width of 60 characters.
+ pterm.DefaultParagraph.WithMaxWidth(60).Println(longText)
+
+ // Print a line space to separate the paragraph from the following text.
pterm.Println()
- // Print long text without paragraph printer.
- pterm.Println("This text is written with the default Println() function. No intelligent splitting here." +
- "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
+ // Define another long text to be printed without a paragraph printer.
+ longTextWithoutParagraph := "This text is written with the default Println() function. No intelligent splitting here." +
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam"
+
+ // Print the long text without using a paragraph printer.
+ pterm.Println(longTextWithoutParagraph)
}
```
@@ -2538,17 +2933,31 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Enable debug messages.
+ // Enable debug messages in PTerm.
pterm.EnableDebugMessages()
- pterm.Debug.Println("Hello, World!") // Print Debug.
- pterm.Info.Println("Hello, World!") // Print Info.
- pterm.Success.Println("Hello, World!") // Print Success.
- pterm.Warning.Println("Hello, World!") // Print Warning.
- pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
- pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
+ // Print a debug message with PTerm.
+ pterm.Debug.Println("Hello, World!")
+
+ // Print an informational message with PTerm.
+ pterm.Info.Println("Hello, World!")
+
+ // Print a success message with PTerm.
+ pterm.Success.Println("Hello, World!")
+
+ // Print a warning message with PTerm.
+ pterm.Warning.Println("Hello, World!")
+
+ // Print an error message with PTerm. This will also display the filename and line number in the terminal.
+ pterm.Error.Println("Errors show the filename and linenumber inside the terminal!")
+
+ // Print an informational message with PTerm, with line number.
+ // This demonstrates that other PrefixPrinters can also display line numbers.
+ pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!")
+
// Temporarily set Fatal to false, so that the CI won't crash.
- pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
+ // This will print a fatal message with PTerm, but won't terminate the program.
+ pterm.Fatal.WithFatal(false).Println("Hello, World!")
}
```
@@ -2573,22 +2982,33 @@ import (
"github.com/pterm/pterm"
)
-// Slice of strings with placeholder text.
+// Slice of strings representing names of pseudo applications to be downloaded.
var fakeInstallList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chrome pseudo-outlook pseudo-explorer "+
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
- // Create progressbar as fork from the default progressbar.
+ // Create a progressbar with the total steps equal to the number of items in fakeInstallList.
+ // Set the initial title of the progressbar to "Downloading stuff".
p, _ := pterm.DefaultProgressbar.WithTotal(len(fakeInstallList)).WithTitle("Downloading stuff").Start()
+ // Loop over each item in the fakeInstallList.
for i := 0; i < p.Total; i++ {
+ // Simulate a slow download for the 7th item.
if i == 6 {
- time.Sleep(time.Second * 3) // Simulate a slow download.
+ time.Sleep(time.Second * 3)
}
- p.UpdateTitle("Downloading " + fakeInstallList[i]) // Update the title of the progressbar.
- pterm.Success.Println("Downloading " + fakeInstallList[i]) // If a progressbar is running, each print will be printed above the progressbar.
- p.Increment() // Increment the progressbar by one. Use Add(x int) to increment by a custom amount.
- time.Sleep(time.Millisecond * 350) // Sleep 350 milliseconds.
+
+ // Update the title of the progressbar with the current item being downloaded.
+ p.UpdateTitle("Downloading " + fakeInstallList[i])
+
+ // Print a success message for the current download. This will be printed above the progressbar.
+ pterm.Success.Println("Downloading " + fakeInstallList[i])
+
+ // Increment the progressbar by one to indicate progress.
+ p.Increment()
+
+ // Pause for 350 milliseconds to simulate the time taken for each download.
+ time.Sleep(time.Millisecond * 350)
}
}
@@ -2608,44 +3028,49 @@ func main() {
package main
import (
- "github.com/pterm/pterm"
"time"
+
+ "github.com/pterm/pterm"
)
func main() {
+ // Create a multi printer instance from the default one
multi := pterm.DefaultMultiPrinter
+ // Create five progress bars with a total of 100 units each, and assign each a new writer from the multi printer
pb1, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 1")
pb2, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 2")
pb3, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 3")
pb4, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 4")
pb5, _ := pterm.DefaultProgressbar.WithTotal(100).WithWriter(multi.NewWriter()).Start("Progressbar 5")
+ // Start the multi printer
multi.Start()
- // Randomly increment progress bars for demo purposes.
+ // Loop to increment progress bars based on certain conditions
for i := 1; i <= 100; i++ {
- pb1.Increment()
+ pb1.Increment() // Increment the first progress bar at each iteration
if i%2 == 0 {
- pb2.Add(3)
+ pb2.Add(3) // Add 3 units to the second progress bar at every even iteration
}
if i%5 == 0 {
- pb3.Increment()
+ pb3.Increment() // Increment the third progress bar at every fifth iteration
}
if i%10 == 0 {
- pb4.Increment()
+ pb4.Increment() // Increment the fourth progress bar at every tenth iteration
}
if i%3 == 0 {
- pb5.Increment()
+ pb5.Increment() // Increment the fifth progress bar at every third iteration
}
- time.Sleep(time.Millisecond * 50)
+ time.Sleep(time.Millisecond * 50) // Pause for 50 milliseconds at each iteration
}
+ // Stop the multi printer
multi.Stop()
}
@@ -2667,14 +3092,16 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print a section with level one.
+ // Create a section with level one and print it.
pterm.DefaultSection.Println("This is a section!")
- // Print placeholder.
+
+ // Print an informational message.
pterm.Info.Println("And here is some text.\nThis text could be anything.\nBasically it's just a placeholder")
- // Print a section with level two.
+ // Create a section with level two and print it.
pterm.DefaultSection.WithLevel(2).Println("This is another section!")
- // Print placeholder.
+
+ // Print another informational message.
pterm.Info.Println("And this is\nmore placeholder text")
}
@@ -2694,19 +3121,34 @@ func main() {
package main
import (
- "github.com/pterm/pterm"
"log/slog"
+
+ "github.com/pterm/pterm"
)
func main() {
+ // Create a new slog handler with the default PTerm logger
handler := pterm.NewSlogHandler(&pterm.DefaultLogger)
+
+ // Create a new slog logger with the handler
logger := slog.New(handler)
+ // Log a debug message (won't show by default)
logger.Debug("This is a debug message that won't show")
- pterm.DefaultLogger.Level = pterm.LogLevelDebug // Enable debug messages
+
+ // Change the log level to debug to enable debug messages
+ pterm.DefaultLogger.Level = pterm.LogLevelDebug
+
+ // Log a debug message (will show because debug level is enabled)
logger.Debug("This is a debug message", "changedLevel", true)
+
+ // Log an info message
logger.Info("This is an info message")
+
+ // Log a warning message
logger.Warn("This is a warning message")
+
+ // Log an error message
logger.Error("This is an error message")
}
@@ -2791,26 +3233,49 @@ func main() {
package main
import (
- "github.com/pterm/pterm"
"time"
+
+ "github.com/pterm/pterm"
)
func main() {
+ // Create a multi printer. This allows multiple spinners to print simultaneously.
multi := pterm.DefaultMultiPrinter
+ // Create and start spinner 1 with a new writer from the multi printer.
+ // The spinner will display the message "Spinner 1".
spinner1, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Spinner 1")
+
+ // Create and start spinner 2 with a new writer from the multi printer.
+ // The spinner will display the message "Spinner 2".
spinner2, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Spinner 2")
+
+ // Create and start spinner 3 with a new writer from the multi printer.
+ // The spinner will display the message "Spinner 3".
spinner3, _ := pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Spinner 3")
+ // Start the multi printer. This will start printing all the spinners.
multi.Start()
+ // Wait for 1 second.
time.Sleep(time.Millisecond * 1000)
+
+ // Stop spinner 1 with a success message.
spinner1.Success("Spinner 1 is done!")
+
+ // Wait for 750 milliseconds.
time.Sleep(time.Millisecond * 750)
+
+ // Stop spinner 2 with a failure message.
spinner2.Fail("Spinner 2 failed!")
+
+ // Wait for 500 milliseconds.
time.Sleep(time.Millisecond * 500)
+
+ // Stop spinner 3 with a warning message.
spinner3.Warning("Spinner 3 has a warning!")
+ // Stop the multi printer. This will stop printing all the spinners.
multi.Stop()
}
@@ -2832,12 +3297,16 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Create styles as new variables
+ // Define a primary style with light cyan foreground, gray background, and bold text
primary := pterm.NewStyle(pterm.FgLightCyan, pterm.BgGray, pterm.Bold)
+
+ // Define a secondary style with light green foreground, white background, and italic text
secondary := pterm.NewStyle(pterm.FgLightGreen, pterm.BgWhite, pterm.Italic)
- // Use created styles
+ // Print "Hello, World!" with the primary style
primary.Println("Hello, World!")
+
+ // Print "Hello, World!" with the secondary style
secondary.Println("Hello, World!")
}
@@ -2845,9 +3314,9 @@ func main() {
-### table/boxed
+### table/demo
-
+
@@ -2859,24 +3328,40 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Create a fork of the default table, fill it with data and print it.
- // Data can also be generated and inserted later.
- pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(pterm.TableData{
+ // Define the data for the first table
+ tableData1 := pterm.TableData{
{"Firstname", "Lastname", "Email", "Note"},
{"Paul", "Dean", "augue@velitAliquam.co.uk", ""},
{"Callie", "Mckay", "nunc.sed@est.com", "这是一个测试, haha!"},
{"Libby", "Camacho", "lobortis@semper.com", "just a test, hey!"},
{"张", "小宝", "zhang@example.com", ""},
- }).Render()
+ }
+
+ // Create a table with a header and the defined data, then render it
+ pterm.DefaultTable.WithHasHeader().WithData(tableData1).Render()
+
+ pterm.Println() // Blank line
+
+ // Define the data for the second table
+ tableData2 := pterm.TableData{
+ {"Firstname", "Lastname", "Email"},
+ {"Paul\n\nNewline", "Dean", "augue@velitAliquam.co.uk"},
+ {"Callie", "Mckay", "nunc.sed@est.com\nNewline"},
+ {"Libby", "Camacho", "lobortis@semper.com"},
+ {"张", "小宝", "zhang@example.com"},
+ }
+
+ // Create another table with a header and the defined data, then render it
+ pterm.DefaultTable.WithHasHeader().WithData(tableData2).Render()
}
```
-### table/demo
+### table/boxed
-
+
@@ -2888,26 +3373,21 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Create a fork of the default table, fill it with data and print it.
- // Data can also be generated and inserted later.
- pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
+ // Define the data for the table.
+ // Each inner slice represents a row in the table.
+ // The first row is considered as the header of the table.
+ tableData := pterm.TableData{
{"Firstname", "Lastname", "Email", "Note"},
{"Paul", "Dean", "augue@velitAliquam.co.uk", ""},
{"Callie", "Mckay", "nunc.sed@est.com", "这是一个测试, haha!"},
{"Libby", "Camacho", "lobortis@semper.com", "just a test, hey!"},
{"张", "小宝", "zhang@example.com", ""},
- }).Render()
-
- pterm.Println() // Blank line
+ }
- // Create a table with multiple lines in a row.
- pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
- {"Firstname", "Lastname", "Email"},
- {"Paul\n\nNewline", "Dean", "augue@velitAliquam.co.uk"},
- {"Callie", "Mckay", "nunc.sed@est.com\nNewline"},
- {"Libby", "Camacho", "lobortis@semper.com"},
- {"张", "小宝", "zhang@example.com"},
- }).Render()
+ // Create a table with the defined data.
+ // The table has a header and is boxed.
+ // Finally, render the table to print it.
+ pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(tableData).Render()
}
```
@@ -2928,14 +3408,19 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Create a table with multiple lines in a row and set a row separator.
- pterm.DefaultTable.WithHasHeader().WithRowSeparator("-").WithHeaderRowSeparator("-").WithData(pterm.TableData{
+ // Define the data for the table.
+ data := pterm.TableData{
{"Firstname", "Lastname", "Email"},
{"Paul\n\nNewline", "Dean", "augue@velitAliquam.co.uk"},
{"Callie", "Mckay", "nunc.sed@est.com\nNewline"},
{"Libby", "Camacho", "lobortis@semper.com"},
{"张", "小宝", "zhang@example.com"},
- }).Render()
+ }
+
+ // Create and render the table.
+ // The options are chained in a single line for simplicity.
+ // The table has a header, a row separator, and a header row separator.
+ pterm.DefaultTable.WithHasHeader().WithRowSeparator("-").WithHeaderRowSeparator("-").WithData(data).Render()
}
```
@@ -2956,15 +3441,21 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Create a fork of the default table, fill it with data and print it.
- // Data can also be generated and inserted later.
- pterm.DefaultTable.WithHasHeader().WithRightAlignment().WithData(pterm.TableData{
+ // Define the data for the table.
+ // Each inner slice represents a row in the table.
+ // The first row is considered as the header.
+ tableData := pterm.TableData{
{"Firstname", "Lastname", "Email", "Note"},
{"Paul", "Dean", "augue@velitAliquam.co.uk", ""},
{"Callie", "Mckay", "nunc.sed@est.com", "这是一个测试, haha!"},
{"Libby", "Camacho", "lobortis@semper.com", "just a test, hey!"},
{"张", "小宝", "zhang@example.com", ""},
- }).Render()
+ }
+
+ // Create a table with the defined data.
+ // The table has a header and the text in the cells is right-aligned.
+ // The Render() method is used to print the table to the console.
+ pterm.DefaultTable.WithHasHeader().WithRightAlignment().WithData(tableData).Render()
}
```
@@ -2989,23 +3480,27 @@ import (
)
func main() {
- // Print info.
- pterm.Info.Println("These are the default theme styles.\n" +
- "You can modify them easily to your personal preference,\n" +
- "or create new themes from scratch :)")
+ // Print an informational message about the default theme styles.
+ pterm.Info.Println("These are the default theme styles.\nYou can modify them easily to your personal preference,\nor create new themes from scratch :)")
- pterm.Println() // Print one line space.
+ // Print a blank line for better readability.
+ pterm.Println()
- // Print every value of the default theme with its own style.
+ // Get the value and type of the default theme.
v := reflect.ValueOf(pterm.ThemeDefault)
typeOfS := v.Type()
+ // Check if the type of the default theme is 'pterm.Theme'.
if typeOfS == reflect.TypeOf(pterm.Theme{}) {
+ // Iterate over each field in the default theme.
for i := 0; i < v.NumField(); i++ {
+ // Try to convert the field to 'pterm.Style'.
field, ok := v.Field(i).Interface().(pterm.Style)
if ok {
+ // Print the field name using its own style.
field.Println(typeOfS.Field(i).Name)
}
+ // Pause for a quarter of a second to make the output easier to read.
time.Sleep(time.Millisecond * 250)
}
}
@@ -3031,11 +3526,17 @@ import (
)
func main() {
+ // Define a tree structure using pterm.TreeNode
tree := pterm.TreeNode{
+ // The top node of the tree
Text: "Top node",
+ // The children of the top node
Children: []pterm.TreeNode{{
+ // A child node
Text: "Child node",
+ // The children of the child node
Children: []pterm.TreeNode{
+ // Grandchildren nodes
{Text: "Grandchild node"},
{Text: "Grandchild node"},
{Text: "Grandchild node"},
@@ -3043,6 +3544,7 @@ func main() {
}},
}
+ // Render the tree with the defined structure as the root
pterm.DefaultTree.WithRoot(tree).Render()
}
@@ -3067,37 +3569,37 @@ import (
)
func main() {
- // You can use a LeveledList here, for easy generation.
+ // Define a leveled list to represent the structure of the directories.
leveledList := pterm.LeveledList{
- pterm.LeveledListItem{Level: 0, Text: "C:"},
- pterm.LeveledListItem{Level: 1, Text: "Users"},
- pterm.LeveledListItem{Level: 1, Text: "Windows"},
- pterm.LeveledListItem{Level: 1, Text: "Programs"},
- pterm.LeveledListItem{Level: 1, Text: "Programs(x86)"},
- pterm.LeveledListItem{Level: 1, Text: "dev"},
- pterm.LeveledListItem{Level: 0, Text: "D:"},
- pterm.LeveledListItem{Level: 0, Text: "E:"},
- pterm.LeveledListItem{Level: 1, Text: "Movies"},
- pterm.LeveledListItem{Level: 1, Text: "Music"},
- pterm.LeveledListItem{Level: 2, Text: "LinkinPark"},
- pterm.LeveledListItem{Level: 1, Text: "Games"},
- pterm.LeveledListItem{Level: 2, Text: "Shooter"},
- pterm.LeveledListItem{Level: 3, Text: "CallOfDuty"},
- pterm.LeveledListItem{Level: 3, Text: "CS:GO"},
- pterm.LeveledListItem{Level: 3, Text: "Battlefield"},
- pterm.LeveledListItem{Level: 4, Text: "Battlefield 1"},
- pterm.LeveledListItem{Level: 4, Text: "Battlefield 2"},
- pterm.LeveledListItem{Level: 0, Text: "F:"},
- pterm.LeveledListItem{Level: 1, Text: "dev"},
- pterm.LeveledListItem{Level: 2, Text: "dops"},
- pterm.LeveledListItem{Level: 2, Text: "PTerm"},
- }
-
- // Generate tree from LeveledList.
+ {Level: 0, Text: "C:"},
+ {Level: 1, Text: "Users"},
+ {Level: 1, Text: "Windows"},
+ {Level: 1, Text: "Programs"},
+ {Level: 1, Text: "Programs(x86)"},
+ {Level: 1, Text: "dev"},
+ {Level: 0, Text: "D:"},
+ {Level: 0, Text: "E:"},
+ {Level: 1, Text: "Movies"},
+ {Level: 1, Text: "Music"},
+ {Level: 2, Text: "LinkinPark"},
+ {Level: 1, Text: "Games"},
+ {Level: 2, Text: "Shooter"},
+ {Level: 3, Text: "CallOfDuty"},
+ {Level: 3, Text: "CS:GO"},
+ {Level: 3, Text: "Battlefield"},
+ {Level: 4, Text: "Battlefield 1"},
+ {Level: 4, Text: "Battlefield 2"},
+ {Level: 0, Text: "F:"},
+ {Level: 1, Text: "dev"},
+ {Level: 2, Text: "dops"},
+ {Level: 2, Text: "PTerm"},
+ }
+
+ // Convert the leveled list into a tree structure.
root := putils.TreeFromLeveledList(leveledList)
- root.Text = "Computer"
+ root.Text = "Computer" // Set the root node text.
- // Render TreePrinter
+ // Render the tree structure using the default tree printer.
pterm.DefaultTree.WithRoot(root).Render()
}
diff --git a/vendor/github.com/pterm/pterm/SECURITY.md b/vendor/github.com/pterm/pterm/SECURITY.md
index 27611496..3e4653f8 100644
--- a/vendor/github.com/pterm/pterm/SECURITY.md
+++ b/vendor/github.com/pterm/pterm/SECURITY.md
@@ -8,7 +8,6 @@ PTerm is a command-line interface (CLI) tool library, and we believe the securit
If you discover a security issue in PTerm, please follow these steps:
Open a new issue in the PTerm GitHub repository, describing the security problem in detail.
-Do not disclose any sensitive information or exploit details in the issue, as PTerm is not considered to have any exploitable features.
## 3. Vulnerable Dependencies
If a dependency of PTerm is found to be vulnerable or infected and requires immediate updates, please follow these steps:
diff --git a/vendor/github.com/pterm/pterm/interactive_continue_printer.go b/vendor/github.com/pterm/pterm/interactive_continue_printer.go
index f7e49e8a..4049cde9 100644
--- a/vendor/github.com/pterm/pterm/interactive_continue_printer.go
+++ b/vendor/github.com/pterm/pterm/interactive_continue_printer.go
@@ -2,7 +2,6 @@ package pterm
import (
"fmt"
- "os"
"strings"
"atomicgo.dev/cursor"
@@ -155,7 +154,7 @@ func (p InteractiveContinuePrinter) Show(text ...string) (string, error) {
result = p.Options[p.DefaultValueIndex]
return true, nil
case keys.CtrlC:
- os.Exit(1)
+ internal.Exit(1)
return true, nil
}
return false, nil
diff --git a/vendor/github.com/pterm/pterm/internal/cancelation_signal.go b/vendor/github.com/pterm/pterm/internal/cancelation_signal.go
index ed424daf..33f17cc1 100644
--- a/vendor/github.com/pterm/pterm/internal/cancelation_signal.go
+++ b/vendor/github.com/pterm/pterm/internal/cancelation_signal.go
@@ -9,8 +9,12 @@ func NewCancelationSignal(interruptFunc func()) (func(), func()) {
}
exit := func() {
- if canceled && interruptFunc != nil {
- interruptFunc()
+ if canceled {
+ if interruptFunc != nil {
+ interruptFunc()
+ } else {
+ Exit(1)
+ }
}
}
diff --git a/vendor/github.com/pterm/pterm/internal/exit.go b/vendor/github.com/pterm/pterm/internal/exit.go
new file mode 100644
index 00000000..f07a0045
--- /dev/null
+++ b/vendor/github.com/pterm/pterm/internal/exit.go
@@ -0,0 +1,14 @@
+package internal
+
+import "os"
+
+// ExitFuncType is the type of function used to exit the program.
+type ExitFuncType func(int)
+
+// DefaultExitFunc is the default function used to exit the program.
+var DefaultExitFunc ExitFuncType = os.Exit
+
+// Exit calls the current exit function.
+func Exit(code int) {
+ DefaultExitFunc(code)
+}
diff --git a/vendor/github.com/pterm/pterm/logger.go b/vendor/github.com/pterm/pterm/logger.go
index 4fed9283..26eea5b0 100644
--- a/vendor/github.com/pterm/pterm/logger.go
+++ b/vendor/github.com/pterm/pterm/logger.go
@@ -200,6 +200,9 @@ func (l Logger) AppendKeyStyle(key string, style Style) *Logger {
// CanPrint checks if the logger can print a specific log level.
func (l Logger) CanPrint(level LogLevel) bool {
+ if l.Level == LogLevelDisabled {
+ return false
+ }
return l.Level <= level
}
@@ -261,7 +264,7 @@ func (l Logger) combineArgs(args ...[]LoggerArgument) []LoggerArgument {
}
func (l Logger) print(level LogLevel, msg string, args []LoggerArgument) {
- if l.Level > level {
+ if !l.CanPrint(level) {
return
}
diff --git a/vendor/github.com/pterm/pterm/slog_handler.go b/vendor/github.com/pterm/pterm/slog_handler.go
index d0854d04..a2b2acfe 100644
--- a/vendor/github.com/pterm/pterm/slog_handler.go
+++ b/vendor/github.com/pterm/pterm/slog_handler.go
@@ -48,17 +48,24 @@ func (s *SlogHandler) Handle(ctx context.Context, record slog.Record) error {
// Wrapping args inside another slice to match [][]LoggerArgument
argsWrapped := [][]LoggerArgument{args}
+ logger := s.logger
+
+ // Must be done here, see https://github.com/pterm/pterm/issues/608#issuecomment-1876001650
+ if logger.CallerOffset == 0 {
+ logger = logger.WithCallerOffset(3)
+ }
+
switch level {
case slog.LevelDebug:
- s.logger.Debug(message, argsWrapped...)
+ logger.Debug(message, argsWrapped...)
case slog.LevelInfo:
- s.logger.Info(message, argsWrapped...)
+ logger.Info(message, argsWrapped...)
case slog.LevelWarn:
- s.logger.Warn(message, argsWrapped...)
+ logger.Warn(message, argsWrapped...)
case slog.LevelError:
- s.logger.Error(message, argsWrapped...)
+ logger.Error(message, argsWrapped...)
default:
- s.logger.Print(message, argsWrapped...)
+ logger.Print(message, argsWrapped...)
}
return nil
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 3de59478..675a6cda 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -238,7 +238,7 @@ github.com/pjbgf/sha1cd/ubc
# github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors
-# github.com/pterm/pterm v0.12.71
+# github.com/pterm/pterm v0.12.74
## explicit; go 1.21
github.com/pterm/pterm
github.com/pterm/pterm/internal