Skip to content

Commit

Permalink
feat: adding interactive continue printer
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Davim <luis.davim@sendoso.com>
  • Loading branch information
luisdavim committed Sep 15, 2022
1 parent b319442 commit fd5784f
Show file tree
Hide file tree
Showing 10 changed files with 525 additions and 6 deletions.
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

0 comments on commit fd5784f

Please sign in to comment.