diff --git a/apps/phototool/pt-import b/apps/phototool/pt-import index 59957ef8580..df4c5ee71f3 100755 --- a/apps/phototool/pt-import +++ b/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!" } + } }