Documentation ¶
Index ¶
- Constants
- Variables
- func CreateCmdAction(ctx *cli.Context)
- func CreateToken(token interface{})
- func DeleteCmdAction(ctx *cli.Context)
- func Exec(s string) (string, error)
- func ExecAction(ctx *cli.Context)
- func FindFileAction(ctx *cli.Context)
- func ForkCmdAction(ctx *cli.Context)
- func ForkFileAction(ctx *cli.Context)
- func Http(method string, path string, param string) []byte
- func HttpJson(method string, path string, param []byte) []byte
- func LoginAction(ctx *cli.Context)
- func LogoutAction(ctx *cli.Context)
- func PathExists(path string) (bool, error)
- func PullFileAction(ctx *cli.Context)
- func PushFileAction(ctx *cli.Context)
- func ReadToken() ([]byte, error)
- func RegisterAction(ctx *cli.Context)
- func RemoveFileAction(ctx *cli.Context)
- func ResetPasswordAction(ctx *cli.Context)
- func SearchAction(ctx *cli.Context)
- func StarAction(ctx *cli.Context)
- func UpdateAction(ctx *cli.Context)
- func UpdateInfoAction(ctx *cli.Context)
- func UserAction(ctx *cli.Context)
- type Cmd
- type CmdRespond
- type CmdsRespond
- type File
- type FilesDownloadRespond
- type FilesRespond
- type Respond
- func Create(cmd Cmd) Respond
- func CreateFile(file *File) Respond
- func CreateStar(username string) Respond
- func Delete(id string) Respond
- func DeleteFile(id string) Respond
- func ForkCmd(keyword string) Respond
- func ForkFile(keyword string) Respond
- func Login(username string, password string) Respond
- func Register(username string, password string) Respond
- func ResetPassword(password string) Respond
- func UpdateInfo(info string) Respond
- type StarUser
- type StarsRespond
- type User
- type UserResult
- type UsersRespond
Constants ¶
View Source
const ( SUCCESS = "0000" ERROR = "0001" )
View Source
const (
URL = "http://cmdp.yurencloud.com/v1"
)
Variables ¶
View Source
var ( // cmd VersionCommand = cli.Command{ Name: "version", Usage: "show version", Aliases: []string{"v"}, Action: func(ctx *cli.Context) { fmt.Println("cmdp version 3.0.0") }, } SearchCommand = cli.Command{ Name: "search", Aliases: []string{"s"}, Usage: "search command, code, account, text, etc.", Action: SearchAction, Flags: []cli.Flag{ cli.IntFlag{ Name: "page,p", Usage: "set page number", Value: 1, }, cli.IntFlag{ Name: "size,s", Usage: "set page size", Value: 20, }, cli.BoolFlag{ Name: "all,a", Usage: "get all commands list", }, }, } CreateCmdCommand = cli.Command{ Name: "create", Aliases: []string{"c"}, Usage: "create command to remote", Action: CreateCmdAction, Flags: []cli.Flag{ cli.BoolFlag{ Name: "public,p", Usage: "set public", }, }, } ForkCmdCommand = cli.Command{ Name: "forkcmd", Aliases: []string{"fc"}, Usage: "fork command, code, account, text, etc.", Action: ForkCmdAction, } DeleteCmdCommand = cli.Command{ Name: "delete", Aliases: []string{"d"}, Usage: "delete command by id", Action: DeleteCmdAction, } ExecCommand = cli.Command{ Name: "exec", Aliases: []string{"e"}, Usage: "exec command", Action: ExecAction, Flags: []cli.Flag{ cli.BoolFlag{ Name: "file,f", Usage: "exec command from file", }, cli.BoolFlag{ Name: "print,p", Usage: "not exec, only print command or file content", }, cli.BoolFlag{ Name: "force,F", Usage: "force exec other user's dangerous command!", }, }, } // user RegisterCommand = cli.Command{ Name: "register", Usage: "user register", Action: RegisterAction, } LoginCommand = cli.Command{ Name: "login", Usage: "login by username and password", Action: LoginAction, } LogoutCommand = cli.Command{ Name: "logout", Usage: "logout", Action: LogoutAction, } ResetPasswordCommand = cli.Command{ Name: "reset", Usage: "reset password", Action: ResetPasswordAction, } UpdateInfoCommand = cli.Command{ Name: "info", Usage: "update user introduction", Action: UpdateInfoAction, } // file PushFileCommand = cli.Command{ Name: "push", Aliases: []string{"p"}, Usage: "push your file to remote", Action: PushFileAction, Flags: []cli.Flag{ cli.BoolFlag{ Name: "public,p", Usage: "set public", }, }, } ForkFileCommand = cli.Command{ Name: "forkfile", Aliases: []string{"ff"}, Usage: "fork file.", Action: ForkFileAction, } PullFileCommand = cli.Command{ Name: "pull", Aliases: []string{"l", "pl", "P"}, Usage: "pull your file from remote", Action: PullFileAction, Flags: []cli.Flag{ cli.BoolFlag{ Name: "print,p", Usage: "not download, only print file content", }, }, } FindFileCommand = cli.Command{ Name: "find", Aliases: []string{"f"}, Usage: "find your files from remote by keyword", Action: FindFileAction, Flags: []cli.Flag{ cli.IntFlag{ Name: "page,p", Usage: "set page number", Value: 1, }, cli.IntFlag{ Name: "size,s", Usage: "set page size", Value: 20, }, cli.BoolFlag{ Name: "all,a", Usage: "get all files list", }, }, } RemoveFileCommand = cli.Command{ Name: "remove", Aliases: []string{"r"}, Usage: "remove your remote file by id", Action: RemoveFileAction, } // star StarCommand = cli.Command{ Name: "star", Usage: "star other user", Action: StarAction, Flags: []cli.Flag{ cli.IntFlag{ Name: "page,p", Usage: "set page number", Value: 1, }, cli.IntFlag{ Name: "size,s", Usage: "set page size", Value: 20, }, cli.IntFlag{ Name: "delete,d", Usage: "delete a star", Value: 0, }, cli.StringFlag{ Name: "keyword,k", Usage: "search star by keyword", Value: "", }, }, } UpdateCommand = cli.Command{ Name: "update", Usage: "update cmdp version", Action: UpdateAction, } UserCommand = cli.Command{ Name: "user", Aliases: []string{"u"}, Usage: "search users, order by stars count desc, cmds count desc, files count desc", Action: UserAction, Flags: []cli.Flag{ cli.IntFlag{ Name: "page,p", Usage: "set page number", Value: 1, }, cli.IntFlag{ Name: "size,s", Usage: "set page size", Value: 20, }, cli.BoolFlag{ Name: "all,a", Usage: "get all users list", }, cli.BoolFlag{ Name: "official,o", Usage: "get all official account list", }, }, } )
Functions ¶
func CreateCmdAction ¶
func CreateToken ¶
func CreateToken(token interface{})
func DeleteCmdAction ¶
func ExecAction ¶
func FindFileAction ¶
func ForkCmdAction ¶
func ForkFileAction ¶
func LoginAction ¶
func LogoutAction ¶
func PathExists ¶
func PullFileAction ¶
func PushFileAction ¶
func RegisterAction ¶
func RemoveFileAction ¶
func ResetPasswordAction ¶
func StarAction ¶
func UpdateAction ¶
func UpdateInfoAction ¶
func UserAction ¶
Types ¶
type Cmd ¶
type Cmd struct { Id int UserId int Cmd string Keyword string Comment string Private bool CreatedAt time.Time UpdatedAt time.Time }
所有命令,代码 都保存在这个表中
type CmdRespond ¶
func GetCmd ¶
func GetCmd(keyword string) CmdRespond
type CmdsRespond ¶
func DeleteStar ¶
func DeleteStar(id int) CmdsRespond
type FilesDownloadRespond ¶
func DownloadFile ¶
func DownloadFile(keyword string) FilesDownloadRespond
type FilesRespond ¶
func SearchFile ¶
func SearchFile(keyword string, page int, size int) FilesRespond
type Respond ¶
func CreateFile ¶
func CreateStar ¶
func DeleteFile ¶
func ResetPassword ¶
func UpdateInfo ¶
type StarsRespond ¶
func SearchStar ¶
func SearchStar(page int, size int, keyword string) StarsRespond
type UserResult ¶
type UsersRespond ¶
type UsersRespond struct { Status string Message string Data []UserResult }
func SearchUser ¶
func SearchUser(page int, size int, keyword string, official string) UsersRespond
Click to show internal directories.
Click to hide internal directories.