apps/phototool: fix initialisation and add collection selector

wip/nixpkgs-raku
Katharina Fey 3 years ago
parent bb208bea31
commit a5d0e038cc
Signed by: kookie
GPG Key ID: F972AEEA2887D547
  1. 52
      apps/phototool/pt-import

@ -5,18 +5,60 @@
subset path of Str;
subset ID of Str;
multi sub MAIN("--version")
my Str $VERSION = "0.1.0";
my regex date_test { ^\d ** 4 . \d ** 2 };
sub list_collections(path $store) {
(dir($store).sort: *.basename).reverse
}
#== validate date
sub validate($date) {
so $date ~~ &date_test
}
sub create_new($store, $name) {
say "Creating path $store$name"
}
multi sub MAIN(Bool :$version!)
{
say "pt-import 0.1.0"
say "pt-import $VERSION";
}
multi sub MAIN(
$src, #= Source of image data (on SD card)
$store, #= Directory of darktable collections
path $src, #= Source of image data (on SD card)
path $store, #= Directory of darktable collections
ID :$start-id, #= The start image ID to import
ID :$end-Id, #= The end image ID to import
Bool :$verbose, #= Display verbose output
)
{
say "execute main function"
say "=== phototool import $VERSION ===";
#== Select or create a collection
say "Select colletion to import into...";
my @collections = 1..* Z list_collections($store);
say "[0] Create a new collection...";
for @collections -> ($idx, $d) {
say "[$idx] {$d.basename}";
}
my $select = prompt "> ";
given $select {
when 0 {
my $date = prompt "Collection date (YYYY.MM) > ";
my $name = prompt "Collection name > ";
if validate($date) {
create_new($store, "$date $name")
} else {
say "Invalid date! $date";
}
}
when 1..@collections.length {
say "Selecting {@collections[$select]}"; }
default { say "Invalid selection!" }
}
}

Loading…
Cancel
Save