A utility to mark and operate on files in the shell.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.0 KiB

  1. #!/usr/bin/env perl
  2. =pod
  3. =head1 NAME
  4. marks-add - add files to the current set of marked files
  5. =head1 SYNOPSIS
  6. marks-add: stashes a filesystem path for use with other utilities
  7. USAGE:
  8. marks add path_to_mark
  9. EXAMPLE:
  10. marks add *.txt
  11. cd ~/notes
  12. marks mv
  13. =head1 AUTHOR
  14. Brennen Bearnes
  15. =cut
  16. use warnings;
  17. use strict;
  18. use 5.10.0;
  19. use App::MarkFiles qw(add);
  20. use Cwd qw(cwd abs_path);
  21. use Getopt::Long;
  22. use Pod::Usage;
  23. my $from_file;
  24. GetOptions(
  25. # 'config=s' => \$config_file,
  26. 'file|f' => \$from_file,
  27. help => sub { pod2usage(0) },
  28. ) or pod2usage(2);
  29. if ($from_file) {
  30. # Use either the contents of files or standard input:
  31. while (<>) {
  32. chomp;
  33. next unless length $_;
  34. # TODO: This doesn't handle ~ expansion - use File::Glob?
  35. # Not really a problem for things coming in as params
  36. # from the shell, but it could well break user expectations
  37. # in files.
  38. add(abs_path($_));
  39. }
  40. } else {
  41. # Use arguments as filenames to add:
  42. add(map { abs_path($_) } @ARGV);
  43. }