88 lines
2.0 KiB
Go
88 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func (util *Util) AddFileCmds() {
|
|
var subCmd = &cobra.Command{
|
|
Use: "file",
|
|
Short: "File operation",
|
|
}
|
|
var putFileCmd = &cobra.Command{
|
|
Use: "put",
|
|
Short: "Put file to storage",
|
|
Run: util.PutFile,
|
|
}
|
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Username, "username", "u", "", "Username")
|
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Password, "password", "p", "", "Password")
|
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Source, "source", "s", "", "Source path")
|
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Dest, "dest", "d", "", "Desctination path")
|
|
|
|
subCmd.AddCommand(putFileCmd)
|
|
|
|
var getFileCmd = &cobra.Command{
|
|
Use: "put",
|
|
Short: "Put file to storage",
|
|
Run: util.PutFile,
|
|
}
|
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Username, "username", "u", "", "Username")
|
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Password, "password", "p", "", "Password")
|
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Source, "source", "s", "", "Source path")
|
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Dest, "dest", "d", "", "Desctination path")
|
|
|
|
subCmd.AddCommand(getFileCmd)
|
|
|
|
util.rootCmd.AddCommand(subCmd)
|
|
}
|
|
|
|
type FileUtil struct {
|
|
fileExists FileExistsParams
|
|
putFileParams PutFileParams
|
|
getFileParams GetFileParams
|
|
deleteFileParams DeleteFileParams
|
|
}
|
|
|
|
// File exists
|
|
type FileExistsParams struct {
|
|
Filepath string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
func (util *Util) FileExists(cmd *cobra.Command, args []string) {
|
|
|
|
}
|
|
|
|
// Put file
|
|
type PutFileParams struct {
|
|
Source string
|
|
Dest string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
func (util *FileUtil) PutFile(cmd *cobra.Command, args []string) {
|
|
}
|
|
|
|
// Get file
|
|
type GetFileParams struct {
|
|
Source string
|
|
Dest string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
func (util *FileUtil) GetFile(cmd *cobra.Command, args []string) {
|
|
}
|
|
|
|
// Delete file
|
|
type DeleteFileParams struct {
|
|
Filepath string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
func (util *FileUtil) DeleteFile(cmd *cobra.Command, args []string) {
|
|
}
|