utils

package
v0.0.0-...-70e62d2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPAE  = errors.New("Error - Product already exist")
	ErrUNKU = errors.New("Error - Unknow user")
	ErrPLE  = errors.New("Error - Product list is empty")
)

Functions

func DeleteCSVItem

func DeleteCSVItem(username string, id int) (err error)

DeleteCSVItem - Remove an item from csv item file

func DoesProductExist

func DoesProductExist(product ProductListing) bool

DoesProductExist - Verify if a product exist

func FindCmd

func FindCmd(command []string) (fullpath string, err error)

FindCmd - Find a command inside ./commands CWD

func GetCSVCategory

func GetCSVCategory(username string, category string, args ...string) (err error)

GetCSVCategory - Show items from a follow category

func GetCSVItem

func GetCSVItem(username string, id int) (err error)

GetCSVItem - Find and return an item from csv item file

func GetCSVTopCategory

func GetCSVTopCategory(username string) (err error)

GetCSVTopCategory - Show the top category with most items

func IsUsernameExist

func IsUsernameExist(username string) bool

IsUsernameExist - Check if user exist

func LastProductId

func LastProductId() int

LastProductId - Gets the latest product ID

func ReGenerateCSVProduct

func ReGenerateCSVProduct(lines [][]string) error

ReGenerateCSVProduct - Regenerates the csv item file

for delete/update operations

func ReadCSVProduct

func ReadCSVProduct() [][]string

ReadCSVProduct - Read all items from a csv item file

func SetPrompt

func SetPrompt(arg ...string) string

SetPrompt - Set prompt

func UpdateCSVItem

func UpdateCSVItem(username string, id int, args []string) (err error)

UpdateCSVItem - Find and update an item from csv item file

func WriteCSVProduct

func WriteCSVProduct(product ProductListing) error

WriteCSVProduct - Writes the item into the csv file

func WriteCSVUser

func WriteCSVUser(username string) error

WriteCSVUser - Write username into csv user file

Types

type ProductListing

type ProductListing struct {
	Id          int
	Username    string
	Title       string
	Description string
	Price       int
	Category    string
	CreatedAt   string
}

ProductListing - Structure used to organize the item

type Prompt

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

Prompt - Default prompt shell

Jump to

Keyboard shortcuts

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