Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CpCmd = &cobra.Command{ Use: "cp [SOURCE...] [DESTINATION]", Short: "Copy files between local and remote locations", Long: `The cp command allows you to copy files between your local machine and a remote server. Copy files between your local machine and a remote server using the cp command. This command supports uploading, downloading, and specifying authentication details such as username and groupname. Example usages: - To upload multiple files to a remote server: alpacon cp /local/path/file1.txt /local/path/file2.txt [SERVER_NAME]:/remote/path/ - To upload or download directory: alpacon cp -r /local/path/directory [SERVER_NAME]:/remote/path/ alpacon cp -r [SERVER_NAME]:/remote/path/directory /local/path/ - To download files from a remote server to a local destination: alpacon cp [SERVER_NAME]:/remote/path1 /remote/path2 /local/destination/path - To specify username: alpacon cp /local/path/file.txt [USER_NAME]@[SERVER_NAME]:/remote/path/ alpacon cp -u [USER_NAME] /local/path/file.txt [SERVER_NAME]:/remote/path/ - To specify groupname: alpacon cp -g [GROUP_NAME] /local/path/file.txt [SERVER_NAME]:/remote/path/ `, Run: func(cmd *cobra.Command, args []string) { username, _ := cmd.Flags().GetString("username") groupname, _ := cmd.Flags().GetString("groupname") recursive, _ := cmd.Flags().GetBool("recursive") if len(args) < 2 { utils.CliError("You must specify at least two arguments.") return } for i, arg := range args { if strings.Contains(arg, "@") && strings.Contains(arg, ":") { parts := strings.SplitN(arg, "@", 2) if username == "" { username = parts[0] } args[i] = parts[1] } } sources := args[:len(args)-1] dest := args[len(args)-1] alpaconClient, err := client.NewAlpaconAPIClient() if err != nil { utils.CliError("Connection to Alpacon API failed: %s. Consider re-logging.", err) return } if isLocalPaths(sources) && isRemotePath(dest) { uploadObject(alpaconClient, sources, dest, username, groupname, recursive) } else if isRemotePath(sources[0]) && isLocalPath(dest) { downloadObject(alpaconClient, sources[0], dest, username, groupname, recursive) } else { utils.CliError("Invalid combination of source and destination paths.") } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.