Skip to content

DRY SCP Command, add Copy command#15

Merged
noorvir merged 9 commits intomasterfrom
callum/unw-184
Jun 1, 2023
Merged

DRY SCP Command, add Copy command#15
noorvir merged 9 commits intomasterfrom
callum/unw-184

Conversation

@caldempsey
Copy link
Copy Markdown
Contributor

@caldempsey caldempsey commented Jun 1, 2023

This pull request (PR) adds the Copy command to the Unweave CLI. The approach is to reuse the existing CopySource function but modify it slightly to make it more versatile, which prevents a large diff.

Before merging, we may want to consider adding some quality-of-life (QoL) improvements such as:

  • Introducing specialized wildcards, like using . to specify the current directory and all its contents.
  • Implementing safeguards to ignore SCP to dangerous paths, such as /, /etc, /var, or /user, on the remote or host.
  • Adding an "in progress" indicator for large copies since copying the entire CLI directory can take time.
  • Automatically creating the destination directory if it does not exist on the remote.

Example flow:

  1. go run . copy /home/mmacheerpuppy/foobar sess:moon-tears-brass-met/home/
  2. Make changes to foobar
  3. go run . copy sess:moon-tears-brass-met/home/foobar /home/mmacheerpuppy/barfoo

@caldempsey caldempsey requested a review from noorvir June 1, 2023 15:41
} else if input == "sess:" {
return "", fmt.Errorf("ExecId not specified")
} else {
return "", nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat confusing. I'd expect this to return an error if the exec wasn't parsed. I see you can some conditional logic above for the case where you handle the empty string case.

If this works it's fine and we can refactor later. Just hard to follow the logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i see what you mean, i'll try to think about a re-write of this in the next pass, but it works for the for loop

@caldempsey caldempsey requested a review from noorvir June 1, 2023 16:06
@noorvir noorvir merged commit 670e3d6 into master Jun 1, 2023
@noorvir noorvir deleted the callum/unw-184 branch June 1, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants