Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EditCmd = &cobra.Command{ Use: "edit [USER@]SERVER:PATH", Short: "Edit a remote file with your local editor", Long: `Download a single remote file, open it in your local editor, and upload changes back to the original path when the editor exits. The command uses the same WebFTP transport and permission behavior as 'alpacon cp'. Use -u/--username and -g/--groupname the same way you would with 'alpacon cp'. Interactive browser login requires an active WorkSession with the webftp scope. The file is downloaded in full before editing; files larger than 10 MB prompt for confirmation (skipped with --force) before opening in the editor. This edits existing remote files only—the file is downloaded first, so it cannot create a new one. The --editor value is tokenized without a shell (the file path is appended as the last argument), so shell syntax such as pipes, redirections, or '&&' will not work.`, Example: ` alpacon edit my-server:/etc/nginx/nginx.conf alpacon edit my-server:/etc/nginx/nginx.conf --editor "code --wait" alpacon edit my-server:/var/log/large.txt --force`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { editorFlag, _ := cmd.Flags().GetString("editor") usernameFlag, _ := cmd.Flags().GetString("username") groupname, _ := cmd.Flags().GetString("groupname") force, _ := cmd.Flags().GetBool("force") flagWorkSession, _ := cmd.Flags().GetString("work-session") target, err := parseEditTarget(args[0], usernameFlag) if err != nil { utils.CliErrorWithExit("%s", err) } workSessionID := worksession.ResolveOrExit(flagWorkSession) authMethod := config.ResolveAuthMethod() alpaconClient, err := client.NewAlpaconAPIClient() if err != nil { utils.CliErrorWithExit("Connection to Alpacon API failed: %s. Consider re-logging.", err) } deps := realEditDeps(alpaconClient, groupname) result, err := runEdit(editOptions{ Target: target, Editor: editorFlag, Force: force, WorkSessionID: workSessionID, }, deps) if err != nil { printPreservedTempPath(result) utils.HandleWorkSessionError(err, "webftp", target.Server, authMethod, workSessionID) utils.CliErrorWithExit("Failed to edit '%s:%s': %s", target.Server, target.RemotePath, err) } if !result.Changed { utils.CliInfo("No changes") return } utils.CliSuccess("Uploaded changes to %s:%s", target.Server, target.RemotePath) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.