Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mv and cp are not implemented so I wrote a wrapper #5

Closed
g-gundam opened this issue Jan 22, 2022 · 3 comments
Closed

mv and cp are not implemented so I wrote a wrapper #5

g-gundam opened this issue Jan 22, 2022 · 3 comments

Comments

@g-gundam
Copy link
Contributor

harvest/src/harvest.lua

Lines 168 to 178 in a9466f9

cli:command("mv", "move the selection to destination")
:argument('dest','folder to which the selection will be moved')
:action(function(options)
print("TODO: mv to destination: "..options.dest)
end)
cli:command("cp", "copy the selection to destination")
:argument('dest','folder to which the selection will be moved')
:action(function(options)
print("TODO: mv to destination: "..options.dest)
end)

I like the idea behind harvest, and it was pretty close to what I needed for my ~/Downloads cleanup project, but I saw that the mv and cp commands were not implemented yet. However, it seemed like I could make a wrapper around the current unfinished harvest and implement cp and mv myself. The result was hvst.

Usage:
  hvst
  hvst help
  hvst cp <TYPE> <DEST> [OPTION]...
  hvst mv <TYPE> <DEST> [OPTION]...

Examples:

  # Display help message.
  hvst help

  # List files in current directory.
  hvst

  # Copy all images to ~/Pictures.
  hvst cp image ~/Pictures

  # Copy all images to ~/Pictures and be verbose.
  hvst cp image ~/Pictures --verbose

  # Show what would happen if we tried to move all images to ~/Pictures/YYYY/MM.
  hvst mv image '@"~/Pictures/$_->{year}/$_->{month}"' --recon

  # Move all images to ~/Pictures/YYYY/MM.
  hvst mv image '@"~/Pictures/$_->{year}/$_->{month}"'

  # Both cp and mv commands take --verbose and --recon (or -v and -r for short).

I'm posting here in case someone finds this useful.

@jaromil
Copy link
Member

jaromil commented Jan 22, 2022

@g-gundam thanks. the cp and mv are implemented in the older zsh version, but the new rewrite in lua needs polishing ( "works for me" basically ). will have a look at your code, would be nice to join hobby forces 😅

@g-gundam
Copy link
Contributor Author

@jaromil I'm in a works-for-me situation myself since my wrapper implements the functionality I needed. I feel like I captured the spirit of what harvest was trying to accomplish, but it is admittedly a quick and dirty hack done in a different language. If the desire to learn Lua becomes strong enough, I may fill in some of the blanks in the Lua implementation. However, for now, I'm going to thank you for doing the file scanning and categorization work that I was able to build upon. It let me clean up my ~/Downloads and ~/Pictures directory which was a mess, and it will help me keep it clean going forward.

@jaromil
Copy link
Member

jaromil commented Jan 26, 2022

No need to rewrite in another language I think is fine like that as long as it is reliable for the delicate task.

I read the code and seems very concise, which is a great plus.

Hope you don't mind if I include it inside harvest?

would you like to commit it yourself as a PR here? inside subdir hvst is OK

@g-gundam g-gundam mentioned this issue Jan 26, 2022
@jaromil jaromil closed this as completed Jan 26, 2022
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

No branches or pull requests

2 participants