Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
The script
The command and output:
$ ./setup-new-coding cpp MEM 54 "Provide placement new with properly aligned pointers to sufficient storage capacity"
Success create directory MEM54-CPP-Provide-placement-new-with-properly-aligned-pointers-to-sufficient-storage-capacity.
Create main.cpp.
# When I update rakudo version to 2017.07, and press CTRL+X CTRL+C quit emacs, exception raised:
Unhandled exception: const_n32 NYI
at SeekFromEnd:9154 (/usr/share/perl6/runtime/CORE.setting.moarvm:)
from acosh:9154 (/usr/share/perl6/runtime/CORE.setting.moarvm:)
from localhost:9154 (/usr/share/perl6/runtime/CORE.setting.moarvm:THREAD-ENTRY)
#!/usr/bin/env perl6
sub touch(IO::Path:D $path) {
with $path.open(:w) {
.close;
return True;
}
False;
}
sub prompt(Str $str) {
say $str;
}
sub run-emacs(IO::Path:D $path) {
my $proc = Proc::Async.new('emacs', '-nw', $path.path);
await $proc.start;
}
proto MAIN(Str , Str , Str , Str ) { * }
multi MAIN(
'cpp',
$rule,
$id,
$descripte
) {
my $dir = "{$rule}{$id}-CPP-" ~ $descripte.subst(/\s+/, "-", :g);
if $dir.IO.mkdir() -> $dp {
prompt "Success create directory {$dir.path}.";
if $dp.add("main.cpp").&touch {
prompt "Create main.cpp.";
run-emacs $dp;
}
} else {
fail "Create directory failed: $!";
}
}
multi MAIN(
'c',
$rule,
$id,
$descripte
) {
my $dir = "{$rule}{$id}-C-" ~ $descripte.subst(/\s+/, "-", :g);
if $dir.IO.mkdir() -> $dp {
prompt "Success create directory {$dir.path}.";
if $dp.add("main.c").&touch {
prompt "Create main.c.";
run-emacs $dp;
}
} else {
fail "Create directory failed: $!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment