Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding interactive continue printer #384

Merged
merged 10 commits into from Sep 19, 2022
31 changes: 28 additions & 3 deletions README.md
Expand Up @@ -90,7 +90,7 @@ which features automatic website generation, automatic deployments, a custom CI-
|✏ Documentation |To view the official documentation of the latest release, you can go to the automatically generated page of [pkg.go.dev](https://pkg.go.dev/github.com/pterm/pterm#section-documentation) This documentation is very technical and includes every method that can be used in PTerm.<br>**For an easy start we recommend that you take a look at the [examples section](#-examples).** Here you can see pretty much every feature of PTerm with example code. The animations of the examples are automatically updated as soon as something changes in PTerm.|

<div align="center">

### Printers (Components)

|Feature|Examples| - |Feature|Examples|
Expand All @@ -113,7 +113,7 @@ which features automatic website generation, automatic deployments, a custom CI-
|---|---|---|
|![Jens Lauterbach](https://avatars.githubusercontent.com/u/1292368?s=25)|[@jenslauterbach](https://github.com/jenslauterbach)|25$|

</div>
</div>

## 🧪 Examples

Expand Down Expand Up @@ -1066,6 +1066,31 @@ func boolToText(b bool) string {

</details>

### interactive_continue/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_continue/demo/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}

```

</details>

### interactive_multiselect/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/demo/animation.svg)
Expand Down Expand Up @@ -1608,7 +1633,7 @@ func main() {

<!-- examples:end -->


---

> GitHub [@pterm](https://github.com/pterm) &nbsp;&middot;&nbsp;
Expand Down
25 changes: 25 additions & 0 deletions _examples/README.md
Expand Up @@ -938,6 +938,31 @@ func boolToText(b bool) string {

</details>

### interactive_continue/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_continue/demo/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}

```

</details>

### interactive_multiselect/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/demo/animation.svg)
Expand Down
25 changes: 25 additions & 0 deletions _examples/interactive_continue/README.md
@@ -0,0 +1,25 @@
### interactive_continue/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_continue/demo/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}

```

</details>

18 changes: 18 additions & 0 deletions _examples/interactive_continue/demo/README.md
@@ -0,0 +1,18 @@
# interactive_continue/demo

![Animation](animation.svg)

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}

```
10 changes: 10 additions & 0 deletions _examples/interactive_continue/demo/animation.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions _examples/interactive_continue/demo/ci.go
@@ -0,0 +1,19 @@
package main

import (
"os"
"time"

"atomicgo.dev/keyboard"
)

// ------ Automation for CI ------
// You can ignore this function, it is used to automatically run the demo and generate the example animation in our CI system.
func init() {
if os.Getenv("CI") == "true" {
go func() {
time.Sleep(time.Second * 2)
keyboard.SimulateKeyPress('y')
}()
}
}
11 changes: 11 additions & 0 deletions _examples/interactive_continue/demo/main.go
@@ -0,0 +1,11 @@
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}
31 changes: 28 additions & 3 deletions docs/README.md
Expand Up @@ -90,7 +90,7 @@ which features automatic website generation, automatic deployments, a custom CI-
|✏ Documentation |To view the official documentation of the latest release, you can go to the automatically generated page of [pkg.go.dev](https://pkg.go.dev/github.com/pterm/pterm#section-documentation) This documentation is very technical and includes every method that can be used in PTerm.<br>**For an easy start we recommend that you take a look at the [examples section](#-examples).** Here you can see pretty much every feature of PTerm with example code. The animations of the examples are automatically updated as soon as something changes in PTerm.|

<div align="center">

### Printers (Components)

|Feature|Examples| - |Feature|Examples|
Expand All @@ -113,7 +113,7 @@ which features automatic website generation, automatic deployments, a custom CI-
|---|---|---|
|![Jens Lauterbach](https://avatars.githubusercontent.com/u/1292368?s=25)|[@jenslauterbach](https://github.com/jenslauterbach)|25$|

</div>
</div>

## 🧪 Examples

Expand Down Expand Up @@ -1066,6 +1066,31 @@ func boolToText(b bool) string {

</details>

### interactive_continue/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_continue/demo/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
result, _ := pterm.DefaultInteractiveContinue.Show()
pterm.Println() // Blank line
pterm.Info.Printfln("You answered: %s", result)
}

```

</details>

### interactive_multiselect/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_multiselect/demo/animation.svg)
Expand Down Expand Up @@ -1608,7 +1633,7 @@ func main() {

<!-- examples:end -->


---

> GitHub [@pterm](https://github.com/pterm) &nbsp;&middot;&nbsp;
Expand Down
2 changes: 1 addition & 1 deletion interactive_confirm_printer.go
Expand Up @@ -90,7 +90,7 @@ func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveCon
//
// Example:
// result, _ := pterm.DefaultInteractiveConfirm.Show("Are you sure?")
// pterm.Println(result)
// pterm.Println(result)
func (p InteractiveConfirmPrinter) Show(text ...string) (bool, error) {
var result bool

Expand Down