-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed putils function to not start with
New
- Loading branch information
1 parent
027180c
commit 24fab6b
Showing
11 changed files
with
98 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package putils | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pterm/pterm" | ||
"github.com/pterm/pterm/internal" | ||
) | ||
|
||
// BulletListFromStrings returns a BulletListPrinter with Text using the NewTreeListItemFromString method. | ||
func BulletListFromStrings(s []string, padding string) pterm.BulletListPrinter { | ||
var lis []pterm.BulletListItem | ||
for _, line := range s { | ||
lis = append(lis, BulletListItemFromString(line, padding)) | ||
} | ||
return *pterm.DefaultBulletList.WithItems(lis) | ||
} | ||
|
||
// BulletListItemFromString returns a BulletListItem with a Text. The padding is counted in the Text to define the Level of the ListItem. | ||
func BulletListItemFromString(text string, padding string) pterm.BulletListItem { | ||
s, l := internal.RemoveAndCountPrefix(text, padding) | ||
return pterm.BulletListItem{ | ||
Level: l, | ||
Text: s, | ||
} | ||
} | ||
|
||
// BulletListFromString returns a BulletListPrinter with Text using the NewTreeListItemFromString method, splitting after return (\n). | ||
func BulletListFromString(s string, padding string) pterm.BulletListPrinter { | ||
return BulletListFromStrings(strings.Split(s, "\n"), padding) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package putils | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pterm/pterm" | ||
) | ||
|
||
// LettersFromString creates a Letters object from a string, which is prefilled with the LetterStyle from ThemeDefault. | ||
// You can override the ThemeDefault LetterStyle if you want to. | ||
func LettersFromString(text string) pterm.Letters { | ||
return LettersFromStringWithStyle(text, &pterm.ThemeDefault.LetterStyle) | ||
} | ||
|
||
// LettersFromStringWithStyle creates a Letters object from a string and applies a Style to it. | ||
func LettersFromStringWithStyle(text string, style *pterm.Style) pterm.Letters { | ||
s := strings.Split(text, "") | ||
l := pterm.Letters{} | ||
|
||
for _, s2 := range s { | ||
l = append(l, pterm.Letter{ | ||
String: s2, | ||
Style: style, | ||
}) | ||
} | ||
|
||
return l | ||
} | ||
|
||
// LettersFromStringWithRGB creates a Letters object from a string and applies an RGB color to it (overwrites style). | ||
func LettersFromStringWithRGB(text string, rgb pterm.RGB) pterm.Letters { | ||
s := strings.Split(text, "") | ||
l := pterm.Letters{} | ||
|
||
for _, s2 := range s { | ||
l = append(l, pterm.Letter{ | ||
String: s2, | ||
Style: &pterm.Style{}, | ||
RGB: rgb, | ||
}) | ||
} | ||
|
||
return l | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters