diff --git a/go.mod b/go.mod index a37644af..5a2a9910 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/magefile/mage v1.15.0 github.com/matryer/is v1.4.1 - github.com/pterm/pterm v0.12.73 + github.com/pterm/pterm v0.12.74 github.com/ztrue/tracerr v0.4.0 golang.org/x/mod v0.14.0 ) diff --git a/go.sum b/go.sum index f6671ba6..f96f71d9 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,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.73 h1:Z//pqnLY9K0Y+1rKGmHedsRIFvWa7JM2WzvjfpNQMFI= -github.com/pterm/pterm v0.12.73/go.mod h1:+M33aZWQVpmLmLbvjykyGZ4gAfeebznRo8JMbabaxQU= +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.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 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 0911599a..c7a37292 100644 --- a/vendor/github.com/pterm/pterm/README.md +++ b/vendor/github.com/pterm/pterm/README.md @@ -135,9 +135,9 @@ go get github.com/pterm/pterm

-### area/center +### area/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/center/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg)
@@ -150,24 +150,37 @@ import ( "time" "github.com/pterm/pterm" + "github.com/pterm/pterm/putils" ) func main() { - // Start a new default area in the center of the terminal. - // The Start() function returns the created area and an error. + // 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() - // 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)) + // 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() - // Pause for a second to simulate a time-consuming task. + // 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 after all updates are done. + // Stop the Area printer after all updates are done. area.Stop() } @@ -175,9 +188,9 @@ func main() {
-### area/default +### area/center -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/default/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/center/animation.svg)
@@ -193,22 +206,21 @@ import ( ) func main() { - // 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() + // 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 + // Loop 5 times to simulate a dynamic update. for i := 0; i < 5; i++ { - // Update the content of the area dynamically. - // Here we're just displaying the current count. + // 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. + // Pause for a second to simulate a time-consuming task. 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() } @@ -216,9 +228,9 @@ func main() {
-### area/demo +### area/default -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/default/animation.svg)
@@ -231,37 +243,25 @@ 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() - - // 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() + // 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() - // Update the Area contents with the current time string. - area.Update(str) + // 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)) - // Sleep for a second before the next update. + // Pause for a second before the next update. time.Sleep(time.Second) } - // Stop the Area printer after all updates are done. + // Stop the area after all updates are done. + // This will clean up and free resources used by the area. area.Stop() } @@ -404,6 +404,47 @@ func main() {
+### barchart/demo + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import ( + "github.com/pterm/pterm" +) + +func main() { + // 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-height ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/custom-height/animation.svg) @@ -518,47 +559,6 @@ func main() { -### barchart/demo - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg) - -
- -SHOW SOURCE - -```go -package main - -import ( - "github.com/pterm/pterm" -) - -func main() { - // 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/horizontal ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/horizontal/animation.svg) @@ -789,6 +789,47 @@ func main() { +### bigtext/demo + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import ( + "github.com/pterm/pterm" + "github.com/pterm/pterm/putils" +) + +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() + + // 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/colored ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/colored/animation.svg) @@ -849,9 +890,9 @@ func main() { -### bigtext/demo +### box/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
@@ -860,30 +901,29 @@ func main() { ```go package main -import ( - "github.com/pterm/pterm" - "github.com/pterm/pterm/putils" -) +import "github.com/pterm/pterm" 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() + // 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 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() + // 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.") - // 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() + // 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) } ``` @@ -935,46 +975,6 @@ func main() {
-### box/demo - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg) - -
- -SHOW SOURCE - -```go -package main - -import "github.com/pterm/pterm" - -func main() { - // 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/title ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/title/animation.svg) @@ -1016,9 +1016,9 @@ func main() { -### bulletlist/customized +### bulletlist/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
@@ -1029,44 +1029,37 @@ package main import ( "github.com/pterm/pterm" + "github.com/pterm/pterm/putils" ) func main() { - // Define a list of bullet list items with different styles and levels. + // Define a list of bullet list items with different 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 - }, + {Level: 0, Text: "Level 0"}, // Level 0 item + {Level: 1, Text: "Level 1"}, // Level 1 item + {Level: 2, Text: "Level 2"}, // Level 2 item } - // Create a bullet list with the defined items and render it. + // 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 -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
@@ -1077,28 +1070,35 @@ package main import ( "github.com/pterm/pterm" - "github.com/pterm/pterm/putils" ) func main() { - // Define a list of bullet list items with different levels. + // Define a list of bullet list items with different styles and 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 + { + 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 + }, } - // Use the default bullet list style to render the list items. + // Create a bullet list with the defined items and render it. 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() } ``` @@ -1778,6 +1778,36 @@ func randomInt(min, max int) int {
+### header/demo + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import "github.com/pterm/pterm" + +func main() { + // Print a default header. + // This uses the default settings of PTerm to print a header. + pterm.DefaultHeader.Println("This is the default header!") + + // Print a spacer line for better readability. + pterm.Println() + + // 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/custom ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/custom/animation.svg) @@ -1810,9 +1840,9 @@ func main() { -### header/demo +### heatmap/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/heatmap/demo/animation.svg)
@@ -1821,19 +1851,29 @@ func main() { ```go package main -import "github.com/pterm/pterm" +import ( + "github.com/pterm/pterm" +) func main() { - // Print a default header. - // This uses the default settings of PTerm to print a header. - pterm.DefaultHeader.Println("This is the default header!") + // 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}, + {0.4, 0.4, -0.3, -1.0, 0.3, -0.2, -0.9, 0.5, -0.3, -1.0, 0.6, -0.2, -0.9}, + {0.9, -0.5, -0.1, 0.3, 1, -0.7, -0.3, 0.1, 0.7, -0.9, -0.5, 0.2, 0.6}, + {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}, + } - // Print a spacer line for better readability. - pterm.Println() + // 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"}, + } - // 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.") + // 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() } ``` @@ -1998,46 +2038,6 @@ func main() {
-### heatmap/demo - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/heatmap/demo/animation.svg) - -
- -SHOW SOURCE - -```go -package main - -import ( - "github.com/pterm/pterm" -) - -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}, - {0.4, 0.4, -0.3, -1.0, 0.3, -0.2, -0.9, 0.5, -0.3, -1.0, 0.6, -0.2, -0.9}, - {0.9, -0.5, -0.1, 0.3, 1, -0.7, -0.3, 0.1, 0.7, -0.9, -0.5, 0.2, 0.6}, - {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"}, - } - - // 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/no_grid ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/heatmap/no_grid/animation.svg) @@ -2200,9 +2200,9 @@ func main() { -### interactive_multiselect/custom-checkmarks +### interactive_multiselect/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/custom-checkmarks/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/demo/animation.svg)
@@ -2212,33 +2212,29 @@ func main() { package main import ( - "atomicgo.dev/keyboard/keys" "fmt" "github.com/pterm/pterm" ) func main() { - // Initialize an empty slice to hold the options + // Initialize an empty slice to hold the options. var options []string - // Populate the options slice with 5 options - 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)) } - // Create a new interactive multiselect printer with the options - // Disable the filter, set the keys for confirming and selecting, and define the checkmark symbols - printer := pterm.DefaultInteractiveMultiselect. - WithOptions(options). - WithFilter(false). - WithKeyConfirm(keys.Enter). - WithKeySelect(keys.Space). - WithCheckmark(&pterm.Checkmark{Checked: pterm.Green("+"), Unchecked: pterm.Red("-")}) + // 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)) + } - // Show the interactive multiselect and get the selected options - selectedOptions, _ := printer.Show() + // 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 + // Print the selected options, highlighted in green. pterm.Info.Printfln("Selected options: %s", pterm.Green(selectedOptions)) } @@ -2246,9 +2242,9 @@ func main() {
-### interactive_multiselect/custom-keys +### interactive_multiselect/custom-checkmarks -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/custom-keys/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/custom-checkmarks/animation.svg)
@@ -2258,7 +2254,6 @@ func main() { package main import ( - "atomicgo.dev/keyboard/keys" "fmt" "github.com/pterm/pterm" ) @@ -2273,12 +2268,11 @@ func main() { } // Create a new interactive multiselect printer with the options - // Disable the filter and set the keys for confirming and selecting options + // Disable the filter and define the checkmark symbols printer := pterm.DefaultInteractiveMultiselect. WithOptions(options). WithFilter(false). - WithKeyConfirm(keys.Enter). - WithKeySelect(keys.Space) + WithCheckmark(&pterm.Checkmark{Checked: pterm.Green("+"), Unchecked: pterm.Red("-")}) // Show the interactive multiselect and get the selected options selectedOptions, _ := printer.Show() @@ -2291,9 +2285,9 @@ func main() {
-### interactive_multiselect/demo +### interactive_multiselect/custom-keys -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/custom-keys/animation.svg)
@@ -2303,29 +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. + // Initialize an empty slice to hold the options var options []string - // Populate the options slice with 100 options. - 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)) } - // 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)) - } + // 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) - // 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() + // Show the interactive multiselect and get the selected options + selectedOptions, _ := printer.Show() - // Print the selected options, highlighted in green. + // Print the selected options pterm.Info.Printfln("Selected options: %s", pterm.Green(selectedOptions)) } @@ -2428,48 +2425,124 @@ func main() { // 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() + // 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) +} + +``` + +
+ +### interactive_textinput/password + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_textinput/password/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import "github.com/pterm/pterm" + +func main() { + // 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)) +} + +``` + +
+ +### logger/demo + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/logger/demo/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import ( + "github.com/pterm/pterm" + "time" +) + +func main() { + // Create a logger with trace level + logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace) + + // Log a trace level message + logger.Trace("Doing not so important stuff", logger.Args("priority", "super low")) - // Print a blank line for better readability in the output. - pterm.Println() + // Pause for 3 seconds + sleep() - // 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) -} + // 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, + } -``` + // Log a debug level message with arguments from the map + logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff)) -
+ // Pause for 3 seconds + sleep() -### interactive_textinput/password + // Log an info level message + logger.Info("That was actually interesting", logger.Args("such", "wow")) -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_textinput/password/animation.svg) + // 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")) -SHOW SOURCE + // Pause for 3 seconds + sleep() -```go -package main + // Log an error level message + logger.Error("Damn, here it is!", logger.Args("error", "something went wrong")) -import "github.com/pterm/pterm" + // Pause for 3 seconds + sleep() -func main() { - // Create an interactive text input with a mask for password input - passwordInput := pterm.DefaultInteractiveTextInput.WithMask("*") + // 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")) - // Show the password input prompt and store the result - result, _ := passwordInput.Show("Enter your password") + // Pause for 3 seconds + sleep() - // Get the default logger from PTerm - logger := pterm.DefaultLogger + // Log a fatal level message + logger.Fatal("Oh no, this process is getting killed!", logger.Args("fatal", true)) +} - // Log the received password (masked) - // Note: In a real-world application, you should never log passwords - logger.Info("Password received", logger.Args("password", result)) +// Function to pause the execution for 3 seconds +func sleep() { + time.Sleep(time.Second * 3) } ``` @@ -2574,82 +2647,6 @@ func main() {
-### logger/demo - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/logger/demo/animation.svg) - -
- -SHOW SOURCE - -```go -package main - -import ( - "github.com/pterm/pterm" - "time" -) - -func main() { - // Create a logger with trace level - logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace) - - // Log a trace level message - logger.Trace("Doing not so important stuff", logger.Args("priority", "super low")) - - // 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, - } - - // Log a debug level message with arguments from the map - logger.Debug("This might be interesting", logger.ArgsFromMap(interstingStuff)) - - // 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/json ![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/logger/json/animation.svg) @@ -2851,9 +2848,9 @@ func main() { -### paragraph/customized +### paragraph/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
@@ -2865,32 +2862,29 @@ package main import "github.com/pterm/pterm" func main() { - // 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, " + + // 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 the long text as a paragraph with a custom maximal width of 60 characters. - pterm.DefaultParagraph.WithMaxWidth(60).Println(longText) + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam") - // Print a line space to separate the paragraph from the following text. + // Printing a line space for separation. pterm.Println() - // 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) + // 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") } ```
-### paragraph/demo +### paragraph/customized -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
@@ -2902,20 +2896,23 @@ package main import "github.com/pterm/pterm" func main() { - // 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, " + + // 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" - // Printing a line space for separation. + // 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() - // 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") + // 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) } ``` @@ -3317,9 +3314,9 @@ func main() {
-### table/boxed +### table/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/boxed/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/demo/animation.svg)
@@ -3331,10 +3328,8 @@ package main import "github.com/pterm/pterm" func main() { - // 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{ + // 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!"}, @@ -3342,19 +3337,31 @@ func main() { {"张", "小宝", "zhang@example.com", ""}, } - // 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() + // 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 -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/boxed/animation.svg)
@@ -3366,8 +3373,10 @@ package main import "github.com/pterm/pterm" func main() { - // Define the data for the first table - tableData1 := 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!"}, @@ -3375,22 +3384,10 @@ func main() { {"张", "小宝", "zhang@example.com", ""}, } - // 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() + // 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() } ``` 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/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 d24b9715..b95428d0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -40,7 +40,7 @@ github.com/matryer/is # github.com/mattn/go-runewidth v0.0.15 ## explicit; go 1.9 github.com/mattn/go-runewidth -# github.com/pterm/pterm v0.12.73 +# github.com/pterm/pterm v0.12.74 ## explicit; go 1.21 github.com/pterm/pterm github.com/pterm/pterm/internal