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.
65 lines
1.5 KiB
65 lines
1.5 KiB
3 years ago
|
#!/usr/bin/env raku
|
||
|
|
||
|
# Define a str type of path
|
||
|
# TODO: validate a path?
|
||
|
subset path of Str;
|
||
|
subset ID of Str;
|
||
|
|
||
3 years ago
|
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!)
|
||
3 years ago
|
{
|
||
3 years ago
|
say "pt-import $VERSION";
|
||
3 years ago
|
}
|
||
|
|
||
|
multi sub MAIN(
|
||
3 years ago
|
path $src, #= Source of image data (on SD card)
|
||
|
path $store, #= Directory of darktable collections
|
||
3 years ago
|
ID :$start-id, #= The start image ID to import
|
||
|
ID :$end-Id, #= The end image ID to import
|
||
|
Bool :$verbose, #= Display verbose output
|
||
|
)
|
||
|
{
|
||
3 years ago
|
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!" }
|
||
|
}
|
||
3 years ago
|
}
|