Skip to content

Commit

Permalink
feat: support setting story width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Jan 12, 2024
1 parent a7dba83 commit 336a211
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/stories/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var CLI struct {
Prefix string `help:"Pre-filter the list of stories." name:"prefix" optional:"" short:"p"`
Single string `help:"Show a single story in full screen, overriding its config." name:"single" optional:"" short:"s"`
Cast string `help:"Save an asciinema cast to the given filename. Must be used in tandem with --single." name:"cast" optional:"" short:"c"`
Width int `help:"Set the width of the terminal when saving an asciinema cast." name:"width" optional:"" short:"w" default:"80"`
Height int `help:"Set the height of the terminal when saving an asciinema cast." name:"height" optional:"" short:"h" default:"26"`
}

func main() {
Expand Down Expand Up @@ -85,7 +87,10 @@ func main() {
}

var cols, rows int = 80, 26
if !haveCast {
if haveCast {
cols = CLI.Width
rows = CLI.Height
} else {
cols, rows, err = term.GetSize(int(os.Stdin.Fd()))
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If your terminal is wider than 80 columns, you'll notice that the pane does not

All actions in `cy`, such as creating panes and switching between them, are triggered by sequences of keys.

{{story cast cy/viewport}}
{{story cast cy/viewport -w 100}}

Here are a few you can try:

Expand Down

0 comments on commit 336a211

Please sign in to comment.