Skip to content
Browse files

Deprecate File::Mkdir, test mkpath() from Shell::Command

  • Loading branch information...
1 parent ed7310a commit 2835717dffd84cf828a01c568728a5454464cc25 @tadzik committed Apr 30, 2011
Showing with 76 additions and 28 deletions.
  1. +5 −0 lib/File/Mkdir.pm
  2. +0 −15 lib/File/Tools.pm
  3. +60 −0 lib/Shell/Command.pm
  4. +0 −13 t/03-file-mkdir.t
  5. +11 −0 t/shell-command.t
View
5 lib/File/Mkdir.pm
@@ -2,6 +2,11 @@ use v6;
module File::Mkdir;
+BEGIN {
+ warn "File::Mkdir is now deprecated, "
+ ~ "please use Shell::Command mkpath() instead";
+}
+
multi sub mkdir(Str $name, $mode = 0o777, :$p!) is export {
for [\~] $name.split('/').map({"$_/"}) {
mkdir($_) unless .IO.d
View
15 lib/File/Tools.pm
@@ -1,15 +0,0 @@
-module File::Tools:<github:tadzik>;
-
-=begin pod
-
-This is a distribution for file-related utilities, including:
-
-=item File::Copy
-=item File::Find
-=item File::Mkdir
-
-Please refer to their documentation for more information.
-
-=end pod
-
-# vim: ft=perl6
View
60 lib/Shell/Command.pm
@@ -0,0 +1,60 @@
+module Shell::Command;
+
+sub cat(*@files) is export {
+ for @files -> $f {
+ given open($f) {
+ for .lines -> $line {
+ say $line;
+ }
+ .close
+ }
+ }
+}
+
+sub eqtime($source, $dest) is export {
+ ???
+}
+
+sub rm_f(*@files) is export {
+ for @files -> $f {
+ unlink $f if $f.IO ~~ :e;
+ }
+}
+
+sub rm_rf(*@files) is export {
+ ???
+}
+
+sub touch(*@files) is export {
+ ???
+}
+
+sub mv(*@args) is export {
+ ???
+}
+
+sub cp(*@args) is export {
+ ???
+}
+
+sub mkpath(*@paths) is export {
+ for @paths -> $name {
+ for [\~] $name.split('/').map({"$_/"}) {
+ mkdir($_) unless .IO.d
+ }
+ }
+}
+
+sub test_f($file) is export {
+ ???
+}
+
+sub test_d($file) is export {
+ ???
+}
+
+sub dos2unix($file) is export {
+ ???
+}
+
+# vim: ft=perl6
View
13 t/03-file-mkdir.t
@@ -1,13 +0,0 @@
-use v6;
-use Test;
-use File::Mkdir;
-plan 3;
-
-mkdir 't/dupa';
-ok ('t/dupa'.IO ~~ :d), 'casual mkdir still works';
-mkdir 't/dupa/foo/bar', :p;
-ok ('t/dupa/foo'.IO ~~ :d), 'mkdir :p, 1/2';
-ok ('t/dupa/foo/bar'.IO ~~ :d), 'mkdir :p, 1/2';
-unlink 't/dupa/foo/bar';
-unlink 't/dupa/foo';
-unlink 't/dupa/';
View
11 t/shell-command.t
@@ -0,0 +1,11 @@
+use v6;
+use Test;
+use Shell::Command;
+plan 2;
+
+mkpath 't/dupa/foo/bar';
+ok ('t/dupa/foo'.IO ~~ :d), 'mkpath, 1/2';
+ok ('t/dupa/foo/bar'.IO ~~ :d), 'mkpath, 1/2';
+unlink 't/dupa/foo/bar';
+unlink 't/dupa/foo';
+unlink 't/dupa/';

0 comments on commit 2835717

Please sign in to comment.
Something went wrong with that request. Please try again.