Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial Perl 6 module starter

  • Loading branch information...
commit 2e400b8b8ee43d60b8a5f151e4ed668d72765e42 0 parents
@moritz authored
Showing with 43 additions and 0 deletions.
  1. +3 −0  README
  2. +40 −0 bin/p6-module-starter
3  README
@@ -0,0 +1,3 @@
+A simple module starter for Perl 6 modules.
+
+This is a work in progress, and not yet recommended for general usage.
40 bin/p6-module-starter
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl6
+
+sub mkdir-p(@a) {
+ for [\~] @a.map({"$_/"}) {
+ mkdir($_) unless .IO.d
+ }
+}
+
+sub MAIN($module-name) {
+ my $module-dir = $module-name.subst(:g, '::', '-');
+ mkdir $module-dir or die "Can't mkdir '$module-dir': $!";
+ chdir $module-dir or die "Can't chdir '$module-dir': $!";
+ my @module-dirs = 'lib', $module-name.split('::');
+ my $file = @module-dirs.pop;
+ mkdir-p @module-dirs;
+ my $module-fn = join '/', @module-dirs, "$file.pm6";
+
+ my $m = open $module-fn, :w;
+ $m.say: 'use v6;';
+ $m.say: "class $module-name;";
+ $m.say: '';
+ $m.say: '# vim: ft=perl6';
+ $m.close;
+
+ mkdir 't';
+ my $t = open :w, 't/01-load.t';
+ $t.say: 'use v6;';
+ $t.say: 'use Test;';
+ $t.say: 'plan *;';
+ $t.say: '';
+ $t.say: "isa_ok {$module-name}.new(), $module-name;";
+ $t.say: '';
+ $t.say: 'done_testing;';
+ $t.say: '# vim: ft=perl6';
+ $t.close;
+
+
+
+}
+# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.