Documentation ¶
Index ¶
- Constants
- func AddFromEditor(name string, enable bool)
- func AddFromFiles(files []string, enable bool, keepFileName bool)
- func DeleteSnippetsFromNames(names []string)
- func DeleteSnippetsFromSelect()
- func DisableGormDebugging()
- func DisableSnippetsFromNames(names []string)
- func DisableSnippetsFromSelect()
- func EnableSnippetsFromNames(names []string)
- func EnableSnippetsFromSelect()
- func FoundSnippet(name string) (r defines.ShellSnippet, e error)
- func GetAllEnabledSnippet() (rs []defines.ShellSnippet, e error)
- func GetAllSnippets() (rs []defines.ShellSnippet, err error)
- func InitDB() error
- func InitRC()
- func ListAndPrint()
- func PrintTarget(r defines.ShellSnippet)
- func SaveSnippet(sn defines.ShellSnippet)
- func SelectSnippet() (r defines.ShellSnippet)
- func SelectSnippets() (rs []defines.ShellSnippet)
- func SelectSnippetsReturnStringSlice() (rs []string)
- type GistFile
- type GistJson
- type GistResponse
- type PasteJson
- type ShareFunction
Constants ¶
View Source
const ( GistApi = "https://api.github.com/gists" PasteBinApi = "https://pastebin.com/api/api_post.php" )
Variables ¶
This section is empty.
Functions ¶
func AddFromEditor ¶
func AddFromFiles ¶
func DeleteSnippetsFromNames ¶
func DeleteSnippetsFromNames(names []string)
func DeleteSnippetsFromSelect ¶
func DeleteSnippetsFromSelect()
func DisableGormDebugging ¶
func DisableGormDebugging()
func DisableSnippetsFromNames ¶
func DisableSnippetsFromNames(names []string)
func DisableSnippetsFromSelect ¶
func DisableSnippetsFromSelect()
func EnableSnippetsFromNames ¶
func EnableSnippetsFromNames(names []string)
func EnableSnippetsFromSelect ¶
func EnableSnippetsFromSelect()
func FoundSnippet ¶
func FoundSnippet(name string) (r defines.ShellSnippet, e error)
func GetAllEnabledSnippet ¶
func GetAllEnabledSnippet() (rs []defines.ShellSnippet, e error)
func GetAllSnippets ¶
func GetAllSnippets() (rs []defines.ShellSnippet, err error)
func ListAndPrint ¶
func ListAndPrint()
func PrintTarget ¶
func PrintTarget(r defines.ShellSnippet)
func SaveSnippet ¶
func SaveSnippet(sn defines.ShellSnippet)
func SelectSnippet ¶
func SelectSnippet() (r defines.ShellSnippet)
func SelectSnippets ¶
func SelectSnippets() (rs []defines.ShellSnippet)
func SelectSnippetsReturnStringSlice ¶
func SelectSnippetsReturnStringSlice() (rs []string)
Types ¶
type GistJson ¶ added in v1.0.0
type GistJson struct { Description string `json:"description"` Public bool `json:"public"` Files map[string]GistFile `json:"files"` }
'{"description":"Example of a gist","public":false,"files":{"README.md":{"content":"Hello World"}}}'
type GistResponse ¶ added in v1.0.0
type GistResponse struct {
Url string `json:"html_url"`
}
type PasteJson ¶ added in v1.0.0
type PasteJson struct { ApiDevKey string `json:"api_dev_key" form:"api_dev_key"` ApiOption string `json:"api_option" form:"api_option"` ApiPasteName string `json:"api_paste_name" form:"api_paste_name"` ApiPasteCode string `json:"api_paste_code" form:"api_paste_code"` ApiPasteFormat string `json:"api_paste_format" form:"api_paste_format"` }
type ShareFunction ¶ added in v1.0.0
type ShareFunction func(t defines.ShellSnippet, secret string) (string, error)
GistResponse r := gout.POST(GistApi).SetHeader(gout.H{ "Accept": "application/vnd.github+json", "Content-Type": "application/json", "Authorization": "Bearer " + s, }).SetJSON(&GistJson{ Description: "Shared by ShellScriptSnippet", Public: true, Files: map[string]GistFile{ fmt.Sprintf("%s.sh", strings.ReplaceAll(t.Name, " ", "_")): {t.Content}, }, }).BindJSON(&gistR).Debug() if log.GlobalLogLevel > log.LogLevelInfo { r.Debug(true) } e := r.Do() if e != nil { return "", e } return gistR.Url, nil }var gistR
string r := gout.POST(PasteBinApi).SetForm(&PasteJson{ ApiDevKey: s, ApiOption: "paste", ApiPasteCode: t.Content, ApiPasteFormat: "bash", ApiPasteName: t.Name, }).BindBody(&str) if log.GlobalLogLevel > log.LogLevelInfo { r.Debug(true) } e := r.Do() if e != nil { return "", e } if !strings.HasPrefix(str, "http") { return str, errors.New("bad request") } return str, nil }var str
Click to show internal directories.
Click to hide internal directories.