Skip to content

Commit

Permalink
bump to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
isacikgoz committed Dec 27, 2018
1 parent ef3e890 commit 76c3f01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ Community driven man pages improved with smart user interaction. **tldr++** sepe
![screenplay](img/screenplay.gif)

## Features
- Interactive
- Fully Interactive (fill the command arguments easily)
- Search from commands to find your desired command (exact + fuzzy search)
- Smart file suggestions (further suggestions will be added)
- Simple implementation
- One of the fastest clients, even fastest (see [Benchmarks](https://github.com/isacikgoz/tldr/wiki/Benchmarks))
- Supports all mainstream platforms and easy to install (Linux, MacOS, Windows)
- Easy to install. Supports all mainstream OS and platforms (Linux, MacOS, Windows)(arm, x86)
- Pure-go (*even contains built-in git*)

## Installation
Expand All @@ -27,6 +28,7 @@ go get -u github.com/isacikgoz/tldr
- [tldr-pages](https://github.com/tldr-pages/tldr)
- [survey](https://github.com/AlecAivazis/survey)
- [go-prompt](https://github.com/c-bata/go-prompt)
- [fuzzy](https://github.com/sahilm/fuzzy)
- [go-git](https://github.com/src-d/go-git)
- [kingpin](https://github.com/alecthomas/kingpin)
- [color](https://github.com/fatih/color)
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (

func main() {

kingpin.Version("tldr++ version 0.3.1")
kingpin.Version("tldr++ version 0.4.0")
kingpin.Parse()

config.StartUp(*clear, *update)
Expand All @@ -31,6 +31,10 @@ func main() {
p, err = pages.QueryRandom()
} else if len(*page) == 0 && !*static {
p, err = pages.ReadAll()
} else if len(*page) == 0 && *static {
config.PrintLogo()
kingpin.Usage()
return
} else {
p, err = pages.Read(*page)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/pages/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func (p *Page) String() string {

// Display returns colored and indented text for rendering output
func (p *Page) Display() string {
s := bold.Sprint(p.Name) + "\n\n" + p.Desc
s := "\n" + bold.Sprint(p.Name) + "\n" + "\n"
if len(p.Desc) > 0 {
s = s + p.Desc + "\n"
}
return s
}
24 changes: 12 additions & 12 deletions pkg/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ func New(p *pages.Page) *Prompt {

// RenderPage prints the tldr man page as is
func (p *Prompt) RenderPage(static bool) error {
if static {
fmt.Println(p.Page.Display())
for _, t := range p.Page.Tips {
fmt.Println("-" + t.Display())
}
return errors.New("")
}
options := make([]string, 0)

for _, t := range p.Page.Tips {
options = append(options, t.Display())
}
core.ErrorTemplate = ""
var mxRows int
if len(p.Page.Tips) > 9 {
mxRows = 9
if len(p.Page.Tips) > 7 {
mxRows = 7
} else {
mxRows = len(p.Page.Tips)
}
Expand All @@ -47,7 +54,7 @@ func (p *Prompt) RenderPage(static bool) error {
{
Name: "Tip",
Prompt: &survey.Select{
Message: "\n" + p.Page.Display() + "\n",
Message: p.Page.Display(),
Options: options,
VimMode: true,
PageSize: mxRows,
Expand All @@ -56,25 +63,18 @@ func (p *Prompt) RenderPage(static bool) error {
Validate: survey.Required,
},
}
if static {
fmt.Println(p.Page.Display())
for _, t := range p.Page.Tips {
fmt.Println("-" + t.Display())
}
return errors.New("")
}
survey.SelectQuestionTemplate = `
{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}}
{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}}
{{- else}}
{{- " "}}(Use{{" "}}{{- color "cyan"}}arrows{{- color "reset"}}` +
` to move,{{" "}}{{- color "cyan"}}type{{- color "reset"}} to filter or{{" "}}` +
` to move,{{" "}}{{- color "cyan"}}type{{- color "reset"}} to search or{{" "}}` +
`{{- color "red"}}ctrl+c{{- color "reset"}} to return{{- if and .Help (not .ShowHelp)}}` +
`. {{""}}{{- color "green"}}{{ HelpInputRune }}{{- color "reset"}} for more{{end}})
{{- if .ShowHelp }}{{"\n"}}{{- color "green"}}{{ HelpIcon }}{{" "}}{{ .Help }}{{color "reset"}}{{end}}
{{- "\n\n"}}
{{- range $ix, $choice := .PageEntries}}
{{- if eq $ix $.SelectedIndex}}{{color "blue+b"}}{{ "-" }} {{else}}{{color "default"}} {{end}}
{{- if eq $ix $.SelectedIndex}}{{color "blue+b"}}{{ "*" }} {{else}}{{color "default"}} {{end}}
{{- $choice}}
{{- color "reset"}}{{"\n"}}
{{- end}}
Expand Down

0 comments on commit 76c3f01

Please sign in to comment.