My personal project and infrastructure archive
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.
 
 
 
 
 
 
nomicon/prototypes/phototool/pt-import

64 lines
1.5 KiB

#!/usr/bin/env raku
# Define a str type of path
# TODO: validate a path?
subset path of Str;
subset ID of Str;
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 $VERSION";
}
multi sub MAIN(
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 "=== 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!" }
}
}