From 9eb115a7e86f7dbc743c60b959c4a36dfda14f27 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 30 Jul 2021 22:42:58 -0700 Subject: [PATCH] projtool.pl: add --dir option to verify subcommand With --dir output the canonical path to the project instead of its name. Signed-off-by: Kyle J. McKay --- toolbox/projtool.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/toolbox/projtool.pl b/toolbox/projtool.pl index 3892c0c..d0df48f 100755 --- a/toolbox/projtool.pl +++ b/toolbox/projtool.pl @@ -10,7 +10,7 @@ use strict; use warnings; use vars qw($VERSION); -BEGIN {*VERSION = \'1.0.4'} +BEGIN {*VERSION = \'1.0.5'} use File::Basename; use Digest::MD5 qw(md5_hex); use IO::Socket; @@ -109,11 +109,13 @@ Usage: %s [...] show show project - verify [--quiet] + verify [--quiet] [--dir] show the canonical project name for (which might - be a path) if and only if it exists. Otherwise display an - error (unless --quiet is used). Exit status will be 0 if - project found, non-zero otherwise. + be a path) if and only if it exists. With --dir show the + canonical full path to the project directory instead. + If the project name is invalid or does not exist, display + an error (unless --quiet is used). Exit status will be 0 + if project found, non-zero otherwise. urls [--push] show available fetch/push URLs for @@ -1222,8 +1224,9 @@ sub cmd_show { sub cmd_verify { use Scalar::Util (); + my $dirfp = 0; my $rt = sub { return ref($_[0]) ? Scalar::Util::reftype($_[0]) : '' }; - parse_options("quiet" => \$quiet); + parse_options("quiet" => \$quiet, "dir" => \$dirfp, "directory" => \$dirfp); @ARGV == 1 or die_usage; my $project = undef; my $pname = undef; @@ -1235,6 +1238,8 @@ sub cmd_verify { !$@ && &$rt($project) ne 'HASH' and $@ = "No such project: \"$ARGV[0]\"\n"; warn $@ if $@ && !$quiet; exit 1 if $@; + $dirfp && defined($project->{path}) && $project->{path} ne "" and + $pname = $project->{path}; printf "%s\n", $pname; return 0; } -- 2.11.4.GIT