cmd

package
v0.0.0-...-9f7a05c Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BookmarkCmd = &cobra.Command{
	Use:     "bookmark",
	Aliases: []string{"bk"},
	Short:   "interact with bookmarks",
	Long:    `This subcommand will allow the user to interact with bookmarks`,
	Run: func(cmd *cobra.Command, args []string) {
		response := makeGetRequest("https://larder.io/api/1/@me/folders/")
		json := getFolders(response)

		bookmarkAddCmd, _ := cmd.Flags().GetString("add")
		bookmarkDeleteCmd, _ := cmd.Flags().GetString("delete")
		bookmarkFolderCmd, _ := cmd.Flags().GetString("folder")
		bookmarkIDCmd, _ := cmd.Flags().GetBool("id")

		if bookmarkAddCmd != "" {
			addBookmark(bookmarkAddCmd, bookmarkFolderCmd)
			os.Exit(0)
		}
		if bookmarkDeleteCmd != "" {
			deleteBookmark(bookmarkDeleteCmd, bookmarkFolderCmd, json.Results)
			os.Exit(0)
		}
		if bookmarkIDCmd {
			getIDFrom(bookmarkFolderCmd, json.Results)
			os.Exit(0)
		}
		cmd.Help()
	},
}
View Source
var FolderCmd = &cobra.Command{
	Use:     "folder",
	Aliases: []string{"fl"},
	Short:   "interact with folders",
	Long:    `This subcommand will allow the user to interact with folders`,
	Run: func(cmd *cobra.Command, args []string) {
		response := makeGetRequest("https://larder.io/api/1/@me/folders/")
		json := getFolders(response)

		folderAddCmd, _ := cmd.Flags().GetString("add")
		folderDeleteCmd, _ := cmd.Flags().GetString("delete")
		folderListCmd, _ := cmd.Flags().GetBool("list")
		folderShowCmd, _ := cmd.Flags().GetString("show")

		var f Folder
		if folderListCmd {
			listFolders(json.Results)
			os.Exit(0)
		}
		if folderAddCmd != "" {
			addFolder(folderAddCmd, f)
			os.Exit(0)
		}
		if folderDeleteCmd != "" {
			deleteFolder(folderDeleteCmd, f)
			os.Exit(0)
		}
		if folderShowCmd != "" {
			showFolder(folderShowCmd, f, json.Results)
			os.Exit(0)
		}
		cmd.Help()
	},
}
View Source
var RefreshTokenCmd = &cobra.Command{
	Use:   "refresh-token",
	Short: "refresh your access token",
	Long:  `This subcommand will automate help refresh your access token`,
	Run: func(cmd *cobra.Command, args []string) {
		refreshAccessToken()
	},
}
View Source
var RootCmd = &cobra.Command{
	Use:   "larder",
	Short: "A CLI to your bookmarks",
	Long:  `A CLI to your bookmarks`,
}
View Source
var SearchCmd = &cobra.Command{
	Use:     "search",
	Aliases: []string{"se"},
	Short:   "search through bookmarks",
	Long:    `This subcommand will allow the user to search through bookmarks`,
	Run: func(cmd *cobra.Command, args []string) {
		params, _ := cmd.Flags().GetString("params")
		if params != "" {
			params := strings.Split(params, ",")
			searchString := buildSearchString(params)
			response := makeGetRequest("https://larder.io/api/1/@me/search/" + searchString)
			json := getBookmarks(response)
			getSearchResults(json.Results)
			os.Exit(0)
		}
		cmd.Help()
	},
}

Functions

func Execute

func Execute()

Types

type Bookmark

type Bookmark struct {
	ID          string      `json:"id"`
	Parent      Tags        `json:"parent"`
	Tags        []Tags      `json:"tags"`
	Title       string      `json:"title"`
	Description string      `json:"description"`
	URL         string      `json:"url"`
	Domain      string      `json:"domain"`
	Created     string      `json:"created"`
	Modified    string      `json:"modified"`
	Meta        interface{} `json:"meta"`
}

type BookmarkAPIResponse

type BookmarkAPIResponse struct {
	Count    int        `json:"count"`
	Next     string     `json:"next"`
	Previous string     `json:"previous"`
	Results  []Bookmark `json:"results"`
}

------------------ COMMAND STRUCTURES ------------------ // -------------------------------------------------------- //

type Config

type Config struct {
	AccessToken  string `yaml:"access_token"`
	RefreshToken string `yaml:"refresh_token"`
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
}

------------------ ~/.larder/config.yml ------------------ // ---------------------------------------------------------- //

type EmptyFolder

type EmptyFolder struct {
	EMPTY_TO string `json:"empty_to"`
}

type Folder

type Folder struct {
	Name   string `json:"name"`
	Parent string `json:"parent"`
}

type FolderAPIResponse

type FolderAPIResponse struct {
	Count    int       `json:"count"`
	Next     string    `json:"next"`
	Previous string    `json:"previous"`
	Results  []Folders `json:"results"`
}

------------------ COMMAND STRUCTURES ------------------ // -------------------------------------------------------- //

type Folders

type Folders struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Color    string   `json:"color"`
	Icon     string   `json:"icon"`
	Created  string   `json:"created"`
	Modified string   `json:"modified"`
	Parent   string   `json:"parent"`
	Folders  []string `json:"folders"`
	Links    int      `json:"Links"`
}

type Tags

type Tags struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Color    string `json:"color"`
	Created  string `json:"created"`
	Modified string `json:"modified"`
}

Jump to

Keyboard shortcuts

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