Skip to content

Commit

Permalink
clean the tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
araraloren committed Apr 1, 2018
1 parent d956ea4 commit 65e57ec
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 358 deletions.
138 changes: 69 additions & 69 deletions bin/fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ my %configs = &loading-config();
&main();

sub main() {
my OptionSet $os .= new;
my OptionSet $os .= new;

$os.push(
'l=a',
Expand Down Expand Up @@ -61,19 +61,19 @@ sub main() {
}
}
@t = @t>>.lc if $ignore-case;
@t;
@t;
};
@t2 = do {
my @t;
@t = ($only && $only ne "w") ?? [] !! ( %no<w> ?? [] !! ($os<w> // []) );
@t = @t>>.lc if $ignore-case;
@t;
@t;
};
my %ext := @t1.Set;
my %whole := @t2.Set;

note "GET ALL EXT\t=> ", %ext if $debug;
note "GET ALL WHOLE\t=> ", %whole if $debug;
note "GET ALL WHOLE\t=> ", %whole if $debug;

my $supplier = Supplier.new;

Expand Down Expand Up @@ -107,68 +107,68 @@ sub main() {
:last
);

my $rv = &getopt( [ %configs, |@*ARGS], $os, parser => &config-loader-parser);

$rv.return-value.{ <w a> } = True;
$category = $rv.return-value;

my $config-io = &determind-local-path().add("findsource");

$os.insert-cmd(
"add",
sub (@fargs) {
for @fargs>>.value -> $file {
given $file.IO {
when .e {
.copy($config-io.add(.basename));
}
default {
die "File {$file} not exists!";
}
}
}
}
);
$os.insert-cmd(
"remove",
sub (@fargs) {
for @fargs>>.value -> $file {
given $file.IO {
when .e {
.unlink;
}
default {
die "Configuration {$file} not exists!";
}
}
}
}
);
$os.insert-cmd(
"list",
sub (@fargs) {
my @configs := $config-io.dir();
put "Not configuration file!" if +@configs == 0;
.basename.put for @configs;
}
);
my $rv = &getopt( [ %configs, |@*ARGS], $os, parser => &config-loader-parser);

$rv.return-value.{ <w a> } = True;
$category = $rv.return-value;

my $config-io = &determind-local-path().add("findsource");

$os.insert-cmd(
"add",
sub (@fargs) {
for @fargs>>.value -> $file {
given $file.IO {
when .e {
.copy($config-io.add(.basename));
}
default {
die "File {$file} not exists!";
}
}
}
}
);
$os.insert-cmd(
"remove",
sub (@fargs) {
for @fargs>>.value -> $file {
given $file.IO {
when .e {
.unlink;
}
default {
die "Configuration {$file} not exists!";
}
}
}
}
);
$os.insert-cmd(
"list",
sub (@fargs) {
my @configs := $config-io.dir();
put "Not configuration file!" if +@configs == 0;
.basename.put for @configs;
}
);

&getopt($rv.noa, [ $os, ]);
}

sub loading-config() is export {
my ConfigSearcher $cs .= new(name => 'findsource');
my %ret;

if $cs.e {
$cs.search();
for $cs.config {
%ret{.config-name} = from-json($_.slurp);
}
}
my ConfigSearcher $cs .= new(name => 'findsource');
my %ret;

if $cs.e {
$cs.search();
for $cs.config {
%ret{.config-name} = from-json($_.slurp);
}
}

return %ret;
}
return %ret;
}

sub basename($filepath) {
return $filepath.substr(($filepath.rindex('/') // -1) + 1);
Expand All @@ -178,15 +178,15 @@ sub get-sub-files($path) {
my @ret := [];
my $dh;

try { # catch when open directory failed
$dh := nqp::opendir($path);
CATCH {
default {
note "Can not open directory: $path";
return @ret;
}
}
}
try { # catch when open directory failed
$dh := nqp::opendir($path);
CATCH {
default {
note "Can not open directory: $path";
return @ret;
}
}
}

while (my $f = nqp::nextfiledir($dh)) {
@ret.push("$path/$f") if $f ne ".." && $f ne ".";
Expand Down
Loading

0 comments on commit 65e57ec

Please sign in to comment.