Skip to content

Commit

Permalink
Merge pull request #371 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 12.70.0
  • Loading branch information
andyone authored Jul 15, 2023
2 parents a17097e + 9d5e151 commit 4908299
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 71 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,14 @@ jobs:
name: Typos
runs-on: ubuntu-latest

continue-on-error: true

needs: SendCoverage

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check spelling
continue-on-error: true
uses: crate-ci/typos@master

Lint:
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## Changelog

### 12.70.0

* `[terminal]` Added flag `HidePassword` for masking passwords while typing
* `[terminal]` Added method `Info` for showing informative messages
* `[terminal]` Added method `Panel` for showing panel with custom label, title, and message
* `[terminal]` Added method `ErrorPanel` for showing panel with error message
* `[terminal]` Added method `WarnPanel` for showing panel with warning message
* `[terminal]` Added method `InfoPanel` for showing panel with informative message
* `[terminal]` Method `PrintErrorMessage` marked as deprecated (_use method `Error` instead_)
* `[terminal]` Method `PrintWarnMessage` marked as deprecated (_use method `Warn` instead_)
* `[fmtc]` Code refactoring
* `[initsystem]` Code refactoring

### 12.69.0

* `[csv]` Added method `WithComma` to CSV reader
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.69.0"
const VERSION = "12.70.0"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
40 changes: 20 additions & 20 deletions fmtc/cond_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func If(cond bool) CondWrapper {
// Print formats using the default formats for its operands and writes to standard
// output.
func (cw CondWrapper) Print(a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -38,7 +38,7 @@ func (cw CondWrapper) Print(a ...any) (int, error) {
// output. Spaces are always added between operands and a newline is appended. It
// returns the number of bytes written and any write error encountered.
func (cw CondWrapper) Println(a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -48,7 +48,7 @@ func (cw CondWrapper) Println(a ...any) (int, error) {
// Printf formats according to a format specifier and writes to standard output. It
// returns the number of bytes written and any write error encountered.
func (cw CondWrapper) Printf(f string, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -59,7 +59,7 @@ func (cw CondWrapper) Printf(f string, a ...any) (int, error) {
// Spaces are added between operands when neither is a string. It returns the
// number of bytes written and any write error encountered.
func (cw CondWrapper) Fprint(w io.Writer, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -70,7 +70,7 @@ func (cw CondWrapper) Fprint(w io.Writer, a ...any) (int, error) {
// Spaces are always added between operands and a newline is appended. It returns
// the number of bytes written and any write error encountered.
func (cw CondWrapper) Fprintln(w io.Writer, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -80,7 +80,7 @@ func (cw CondWrapper) Fprintln(w io.Writer, a ...any) (int, error) {
// Fprintf formats according to a format specifier and writes to w. It returns
// the number of bytes written and any write error encountered.
func (cw CondWrapper) Fprintf(w io.Writer, f string, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -90,7 +90,7 @@ func (cw CondWrapper) Fprintf(w io.Writer, f string, a ...any) (int, error) {
// Sprint formats using the default formats for its operands and returns the
// resulting string. Spaces are added between operands when neither is a string.
func (cw CondWrapper) Sprint(a ...any) string {
if cw.match == false {
if !cw.match {
return ""
}

Expand All @@ -100,7 +100,7 @@ func (cw CondWrapper) Sprint(a ...any) string {
// Sprintf formats according to a format specifier and returns the resulting
// string.
func (cw CondWrapper) Sprintf(f string, a ...any) string {
if cw.match == false {
if !cw.match {
return ""
}

Expand All @@ -111,7 +111,7 @@ func (cw CondWrapper) Sprintf(f string, a ...any) string {
// resulting string. Spaces are always added between operands and a newline is
// appended.
func (cw CondWrapper) Sprintln(a ...any) string {
if cw.match == false {
if !cw.match {
return ""
}

Expand All @@ -120,7 +120,7 @@ func (cw CondWrapper) Sprintln(a ...any) string {

// TPrint removes all content on the current line and prints the new message
func (cw CondWrapper) TPrint(a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -129,7 +129,7 @@ func (cw CondWrapper) TPrint(a ...any) (int, error) {

// TPrintf removes all content on the current line and prints the new message
func (cw CondWrapper) TPrintf(f string, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -139,7 +139,7 @@ func (cw CondWrapper) TPrintf(f string, a ...any) (int, error) {
// TPrintln removes all content on the current line and prints the new message
// with a new line symbol at the end
func (cw CondWrapper) TPrintln(a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -149,7 +149,7 @@ func (cw CondWrapper) TPrintln(a ...any) (int, error) {
// LPrint formats using the default formats for its operands and writes to standard
// output limited by the text size
func (cw CondWrapper) LPrint(maxSize int, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -159,7 +159,7 @@ func (cw CondWrapper) LPrint(maxSize int, a ...any) (int, error) {
// LPrintf formats according to a format specifier and writes to standard output
// limited by the text size
func (cw CondWrapper) LPrintf(maxSize int, f string, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -169,7 +169,7 @@ func (cw CondWrapper) LPrintf(maxSize int, f string, a ...any) (int, error) {
// LPrintln formats using the default formats for its operands and writes to standard
// output limited by the text size
func (cw CondWrapper) LPrintln(maxSize int, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -179,7 +179,7 @@ func (cw CondWrapper) LPrintln(maxSize int, a ...any) (int, error) {
// TLPrint removes all content on the current line and prints the new message
// limited by the text size
func (cw CondWrapper) TLPrint(maxSize int, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -189,7 +189,7 @@ func (cw CondWrapper) TLPrint(maxSize int, a ...any) (int, error) {
// TLPrintf removes all content on the current line and prints the new message
// limited by the text size
func (cw CondWrapper) TLPrintf(maxSize int, f string, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -199,7 +199,7 @@ func (cw CondWrapper) TLPrintf(maxSize int, f string, a ...any) (int, error) {
// TPrintln removes all content on the current line and prints the new message
// limited by the text size with a new line symbol at the end
func (cw CondWrapper) TLPrintln(maxSize int, a ...any) (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -208,7 +208,7 @@ func (cw CondWrapper) TLPrintln(maxSize int, a ...any) (int, error) {

// NewLine prints a newline to standard output
func (cw CondWrapper) NewLine() (int, error) {
if cw.match == false {
if !cw.match {
return 0, nil
}

Expand All @@ -217,7 +217,7 @@ func (cw CondWrapper) NewLine() (int, error) {

// Bell prints alert (bell) symbol
func (cw CondWrapper) Bell() {
if cw.match == false {
if !cw.match {
return
}

Expand Down
2 changes: 1 addition & 1 deletion initsystem/initsystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func hasUpstartService(name string) bool {
}

func hasSystemdService(name string) bool {
if strings.Index(name, ".") == -1 {
if !strings.Contains(name, ".") {
name = name + ".service"
}

Expand Down
65 changes: 58 additions & 7 deletions terminal/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// ////////////////////////////////////////////////////////////////////////////////// //

func ExampleReadUI() {
func ExampleRead() {
// User must enter name
input, err := ReadUI("Please enter user name", true)

Expand All @@ -39,7 +39,7 @@ func ExampleReadPassword() {
MaskSymbol = "•"
MaskSymbolColorTag = "{s}"

// User must enter password
// User must enter the password
password, err := ReadPassword("Please enter password", true)

if err != nil {
Expand All @@ -54,7 +54,7 @@ func ExampleReadPasswordSecure() {
MaskSymbol = "•"
MaskSymbolColorTag = "{s}"

// User must enter password
// User must enter the password
password, err := ReadPasswordSecure("Please enter password", true)

if err != nil {
Expand Down Expand Up @@ -106,12 +106,63 @@ func ExamplePrintActionStatus() {
}
}

func ExamplePrintErrorMessage() {
func ExampleError() {
// Add custom error message prefix
ErrorPrefix = "▲ "

// Print red text to stderr
PrintErrorMessage("Error while sending data")
Error("Error while sending data to %s", "https://example.com")
}

func ExamplePrintWarnMessage() {
func ExampleWarn() {
// Add custom warning message prefix
WarnPrefix = "△ "

// Print yellow text to stderr
PrintWarnMessage("Warning file is not found")
Warn("Warning file %s is not found", "/home/john/test.txt")
}

func ExampleInfo() {
// Add custom info message prefix
InfoPrefix = "❕ "

// Print cyan text to stdout
Warn("User %q will be created automatically", "bob")
}

func ExampleErrorPanel() {
ErrorPanel(
"Can't send data to remote server.",
`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
)
}

func ExampleWarnPanel() {
WarnPanel(
"Can't find user bob on system.",
`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
)
}

func ExampleInfoPanel() {
InfoPanel(
"Auto-saving is enabled - data will be saved after editing.",
`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
)
}

func ExamplePanel() {
Panel(
"Yolo", "{m}",
"Excepteur sint occaecat cupidatat non proident.",
`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
)
}
Loading

0 comments on commit 4908299

Please sign in to comment.