#!/usr/bin/perl use strict; use warnings; =pod =encoding UTF-8 =head1 NAME project-proper-path - Print the proper path of the project based in the working directory =head1 SYNOPSIS project-proper-path perldoc project-proper-path =head1 DESCRIPTION This works as advertised only if the working directory is the base directory of a project. Prints the proper path (without a trailing slash) of the project that is (or would be) installed in the working directory. Fails with an error message if the working directory is detected to be outside of the command directory or one that is structurally mapped to it. =head1 EXAMPLES ~/work/wayic/cast> project-proper-path → wayic/cast ~/var/repo/git/wayic.cast.git> project-proper-path → wayic/cast ~/work/wayic/Waybrec> project-proper-path → wayic/Waybrec ~/var/repo/git/Waybrec.git> project-proper-path → wayic/Waybrec =head1 SEE ALSO http://reluk.ca/project/building/lexicon.brec §§ command directory, proper path project-token-name =cut { my $p =`pwd`; chomp $p; if( $p =~ s"^/home/mike/var/repo/git/(.+)\.git"$1" ) { $p =~ s'\.'/'g; ex: { # Exceptional cases, q.v. in `project-token-name`. $p =~ s"^(Breccia)_to_X-Breccia\b"$1/XML/translator" and last ex; $p =~ s"^(Java)_Mode_Tamed\b"$1/Emacs" and last ex; $p =~ s"^(Makeshift)\b"building/$1" and last ex; $p =~ s"^TMDAng"email/TMDA" and last ex; $p =~ s"^(Waybrec)\b"wayic/$1" and last ex; $p =~ s"^X-(Breccia)\b"$1/XML" and last ex; }} elsif( $p !~ s'^/home/mike/(?:code/WP3|project|work)/'' ) { die "Not a project directory\n"; } print $p; print "\n"; } __END__ =pod =head1 AUTHOR Michael Allan =cut