summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-08-05 12:01:12 +0100
committerdakkar <dakkar@thenautilus.net>2016-08-05 12:01:12 +0100
commit17d9443ee8d459794d90e4c38b04ba6ca4a93c3b (patch)
tree1f8e78994fcad0efdaa18b5314256b082926233c
parentsilence "experimental" warnings (diff)
downloaddobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.tar.gz
dobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.tar.bz2
dobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.zip
allow symbols on the command line
-rwxr-xr-xdobble.pl18
1 files changed, 14 insertions, 4 deletions
diff --git a/dobble.pl b/dobble.pl
index 5040d7a..324b3cd 100755
--- a/dobble.pl
+++ b/dobble.pl
@@ -124,8 +124,14 @@ package CardsTable {
sub load_symbols($file) {
return undef unless $file;
- use Path::Tiny;
- return [ path($file)->lines_utf8 ];
+ require Path::Tiny;
+ return [ Path::Tiny::path($file)->lines_utf8 ];
+}
+
+sub split_symbols($string) {
+ return undef unless $string;
+ require Encode;
+ return [ split //, Encode::decode('utf-8',$string) ];
}
use Getopt::Long::Descriptive;
@@ -134,7 +140,8 @@ my ($opt,$usage) = describe_options(
'%c %o',
[ 'order|o=i', 'order of the finite field', { required => 1 } ],
[ 'padding|p!', 'vertically align symbols', { default => 0 } ],
- [ 'symbols|s=s', 'file with one symbol per line' ],
+ [ 'symbols|s=s', 'string of symbols (one per character)' ],
+ [ 'symbols-from|f=s', 'file with one symbol per line' ],
[],
['help|h', 'show this help text', { shortcircuit => 1 } ],
);
@@ -144,7 +151,10 @@ my $order = $opt->order;
my $plane = FiniteProjectivePlane->new(mod=>$order);
my $table = CardsTable->new(
padding=>$opt->padding,
- symbols => load_symbols($opt->symbols),
+ symbols => (
+ split_symbols($opt->symbols)
+ || load_symbols($opt->symbols_from),
+ ),
);
# sanity check