Skip to content

Commit

Permalink
finally looks good
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Nov 15, 2024
1 parent 2f5d312 commit 600f279
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 24 deletions.
23 changes: 20 additions & 3 deletions bin/distro-lint
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,41 @@ use Mi6::Helper::Utils;
my $parent-dir = $*CWD;
my $dir;
my $debug = 0;

if not @*ARGS {
# usage
lint-usage
lint-help;
exit;
}

my @args;
for @*ARGS {
#say "DEBUG: arg '$_'";
if $_ eq '.' {
$dir = $parent-dir;
}
elsif $_ eq '..' {
my $path = $parent-dir.IO.absolute;
$dir = $path.IO.parent(2).IO;
}
elsif $_.IO.d {
$dir = $_;
}
elsif $_.contains("distro") {
; # ignore
}
elsif $_.contains("dlint") {
; # ignore
}
elsif $_.contains("mi6-helper") {
; # ignore
}
else {
@args.push: $_;
}
}

#say "DEBUG early exit"; exit;

for @args {
when /^ :i L/ {
%*ENV<RAKUDO_NO_PRECOMPILATION> = 1;
Expand All @@ -38,7 +53,9 @@ for @args {
}
}

lint $dir, :$debug;
my $s = lint $dir, :$debug;
say $s;


=finish

Expand Down
48 changes: 38 additions & 10 deletions bin/mi6-helper
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,49 @@
use Mi6::Helper;
use Mi6::Helper::Utils;

if @*ARGS {
# do the work
for @*ARGS {
when /^ :i L/ {
%*ENV<RAKUDO_NO_PRECOMPILATION> = 1;
}
my $parent-dir = $*CWD;
my $dir;
my $debug = 0;
if not @*ARGS {
# usage
mi6-help;
exit;
}

# do the work
my @args;
for @*ARGS {
say "DEBUG: arg '$_'" if $debug;
if $_ eq '.' {
$dir = $parent-dir;
say "DEBUG: dir: '$dir'" if $debug;
}
elsif $_ eq '..' {
my $path = $parent-dir.IO.absolute;
$dir = $path.IO.parent(2);
say "DEBUG: dir: '$dir'" if $debug;
}
elsif $_.IO.d {
$dir = $_;
}
elsif $_.contains("dlint") {
; # ignore
}
elsif $_.contains("distro-lint") {
; # ignore
}
else {
@args.push: $_
}
run-args @*ARGS
}
else {
# usage
help

if not $dir.defined {
$dir = $parent-dir;
}

#@args.unshift: $dir;
run-args $dir, @args;

=finish

# safety checks
Expand Down
21 changes: 21 additions & 0 deletions lib/Mi6/Helper/Subs.rakumod
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
unit module Mi6::Helper::Subs;

use Mi6::Helper::Results;

sub handle-resources(
:$debug,
--> Mi6::Helper::Results
) is export {
} # sub handle-resources

sub handle-modules-used(
:$debug,
--> Mi6::Helper::Results
) is export {
} # sub handle-modules-used

sub handle-old-file-names(
:$debug,
--> Mi6::Helper::Results
) is export {
} # sub handle-old-file-names


22 changes: 11 additions & 11 deletions lib/Mi6/Helper/Utils.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contents.
RESINFO

sub lint-usage() is export {
sub lint-help() is export {
# usage
print qq:to/HERE/;
Usage: {$*PROGRAM.basename} <dir with .git subdir> [options...]
Expand All @@ -45,7 +45,7 @@ sub lint-usage() is export {
exit;
}

sub help() is export {
sub mi6-help() is export {
# usage
say qq:to/HERE/;
Usage: {$*PROGRAM.basename} <mode> [options...]
Expand All @@ -57,22 +57,22 @@ sub help() is export {
'provides' option for a short description of its main purpose.
See details in the README.
lint - Checks for match of entries in the 'resources' directory of the
current directory (default '.', but see NOTE below)) and the
'resources' entries in the 'META6.json' file. Also looks for
other issues.
lint - Checks various issues with the contents of the module
repository directory. For easier use, execute one of
the installed programs 'dlint' or 'distro-lint'.
Options:
dir=X - Selects directory 'X' for the operations, default is '.'
<dir> - Selects directory <dir> for the operations, default is '.'
(the current directory, i.e., '$*CWD').
ver - Shows the version of 'mi6-helper'
NOTE - The default directory will cause an abort if the repository home
of this module is selected.
HERE
} # sub action()
} # sub mi6-help()

sub run-args(@args) is export {
sub run-args($dir, @args) is export {
# do the work

# modes
Expand All @@ -91,7 +91,7 @@ sub run-args(@args) is export {

# assume we are in the current
# working directory
my $parent-dir = $*CWD; # default
my $parent-dir = $dir; #$*CWD; # default

# other args
my $err = 0; # track number of possible errors
Expand Down Expand Up @@ -467,7 +467,7 @@ sub lint(IO::Path:D $dir, :$debug, --> Str) is export {

my $resfils-issues = ""; # used to collect results from resources check
if not (@rfils.elems or @resfils.elems) {
say "DEBUG: neither META6 nor /resources list any files";
say "DEBUG: neither META6 nor /resources list any files" if $debug;
$resfils-issues ~= " No META6<resources> or /resources files found.\n";
}
else {
Expand Down

0 comments on commit 600f279

Please sign in to comment.