tldr

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFoundPage = errors.New("no page found")

Functions

This section is empty.

Types

type CmdExample

type CmdExample struct {
	Description string
	Cmd         string
}

CmdExample a command example in a tldr page

type CmdInfo

type CmdInfo struct {
	Name      string     `json:"name"`
	Platforms []Platform `json:"platform"`
	Languages []string   `json:"language"`
}

CmdInfo contains name, platform, language

type Cmds

type Cmds []*CmdInfo

Cmds a slice of CmdInfo

func (Cmds) Len

func (c Cmds) Len() int

Len return length of Commands for fuzzy interface

func (Cmds) Search

func (c Cmds) Search(args []string) Cmds

Search fuzzy search commands by query.

func (Cmds) String

func (c Cmds) String(i int) string

type CmdsIndex

type CmdsIndex struct {
	Commands Cmds `json:"commands"`
}

CmdsIndex structure of index.json

type Options

type Options struct {
	Platform Platform
	Language string
	Update   bool
}

Options are tldr functions

type Page

type Page struct {
	CmdName         string
	CmdDescriptions []string
	CmdExamples     []*CmdExample
}

Page contents of a tldr page

type Platform

type Platform string
const (
	PlatformCommon  Platform = "common"
	PlatformWindows Platform = "windows"
	PlatformLinux   Platform = "linux"
	PlatformSunos   Platform = "sunos"
	PlatformOSX     Platform = "osx"
)

func (Platform) String

func (pt Platform) String() string

type Tldr

type Tldr struct {
	// contains filtered or unexported fields
}

Tldr Repository of tldir pages

func New

func New(tldrPath string, opt *Options) *Tldr

New create a instance of tldr repository

func (*Tldr) Expired

func (t *Tldr) Expired(ttl time.Duration) bool

Expired return true if tldr repository have passed `ttl`

func (*Tldr) FindPage

func (t *Tldr) FindPage(cmds []string) (*Page, error)

FindPage find tldr page by `cmds`

func (*Tldr) LoadIndexFile

func (t *Tldr) LoadIndexFile() (*CmdsIndex, error)

LoadIndexFile load command index file

func (*Tldr) OnInitialize

func (t *Tldr) OnInitialize() error

OnInitialize create and update tldr directory

func (*Tldr) Update

func (t *Tldr) Update() error

Update tldr pages from remote zip file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL