Skip to content

Commit

Permalink
Merge pull request #5 from mmurphy/optionalpreview
Browse files Browse the repository at this point in the history
Add CLI flag to allow not showing the preview window
  • Loading branch information
esimov authored Oct 31, 2017
2 parents ea97a31 + bf1fd23 commit b488a71
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,37 @@ The application supports the generation of hand drawn diagrams directly via comm

```bash
Usage of diagram:
-font string
path to font file (default "${GOPATH}/src/github.com/esimov/diagram/font/gloriahallelujah.ttf")
-in string
Source
-out string
Destination
-preview
Show the preview window (default true)
```

#### CLI Examples

Read input from `sample.txt` and write image to `sample.png` showing a preview window with the hand drawn diagram

```bash
diagram -in sample.txt -out sample.png
```

Read input from `sample.txt` and write image to `sample.png`, and exit immediately without showing a preview window

```bash
diagram -in sample.txt -out sample.png -preview=false
```

Generate diagram as above but use a font at a different location

```bash
diagram -in sample.txt -out sample.png -preview=false -font /path/to/my/font/MyHandwriting.ttf
```



### Key bindings
Key | Description
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
source = flag.String("in", "", "Source")
destination = flag.String("out", "", "Destination")
fontpath = flag.String("font", defaultFontFile, "path to font file")
preview = flag.Bool("preview", true, "Show the preview window")
)

func main() {
Expand All @@ -32,7 +33,7 @@ func main() {
err := canvas.DrawDiagram(input, *destination, *fontpath)
if err != nil {
log.Fatal("Error on converting the ascii art to hand drawn diagrams!")
} else {
} else if *preview {
image, _ := imview.LoadImage(*destination)
view := imview.ImageToRGBA(image)
imview.Show(view)
Expand Down

0 comments on commit b488a71

Please sign in to comment.