Commit b3917781 authored by Damyan Ivanov's avatar Damyan Ivanov

add "dpt cd" sub-command

parent a14a8db2
......@@ -81,6 +81,10 @@ Show this documentation.
See L<dpt-alioth-author(1)>.
=item B<cd> - change directory to a package working directory
See L<dpt-cd(1)>
=item B<checkout> - work on pkg-perl package
See L<dpt-checkout(1)>.
......
#!/bin/sh
# copyright, licensing and documentation at the end
set -e
set -u
usage() {
perl -MPod::Usage=pod2usage -e"pod2usage(-input => '$0', -verbose=>99, -sections=>[qw(SYNOPSIS DESCRIPTION COMMANDS)])"
exit 1
}
[ -n "${1:-}" ] || usage
[ -z "${2:-}" ] || usage
if [ -z "${DPT_PACKAGES}" ]; then
echo "Required configuration variable DPT_PACKAGES is not set" >&2
echo "See dpt-config(1)" >&2
exit 1
fi
if [ -d ${DPT_PACKAGES}/"$1" ]; then
echo "Package '$1' is in ${DPT_PACKAGES}/$1"
else
echo "Package '$1' not found in ${DPT_PACKAGES}" >&2
exit 1
fi
exit 0
POD=<<'EOF'
=head1 NAME
dpt-cd - change to package's working directory
=head1 SYNOPSIS
B<dpt cd> I<package-name>
=head1 DESCRIPTION
B<dpt cd> puts you in the working copy for the packaging of a given package.
It does not try to update the checkout, nor create it if it does not exist. Use
L<dpt-checkout(1)> for that.
It is a shortcut for when you know that the given checkout is up to date or
when you are offline.
=head1 CAVEATS
Programs cannot change the working directory of the shell. In order to achieve
this you should integrate B<dpt> with your shell. See L<dpt-shell-lib(1)> for
instructions.
=head1 CONFIGURATION
B<dpt checkout> requires the C<DPT_PACKAGES> environment variable.
See L<dpt-config> for details.
=head1 COPYRIGHT & LICENSE
Copyright 2013 Damyan Ivanov L<dmn@debian.org>
This program is free software, licensed under the same term as perl.
=cut
EOF
......@@ -10,8 +10,8 @@
# .
# b) the "Artistic License" which comes with Perl.
#
# the purpose of this is to hijack the 'dpt commit' invocation, parse its
# output, and thange the CWD accordingly
# the purpose of this is to parse the output of 'dpt checkout' and 'dpt cd'
# commands and change the CWD accordingly
dpt() {
REAL=`command which dpt`
......@@ -39,5 +39,11 @@ dpt() {
return 0
fi
if egrep -q "^Package .+ is in .+" "$TMP/out"; then
DIR=`egrep '^Package .+ is in ' "$TMP/out" | sed -e 's/^Package .\+ is in //'`
cd "$DIR"
return 0
fi
return 0
}
......@@ -39,8 +39,8 @@ B<dpt shell-lib> prints out a shell command that loads some goodies when
working with packages from the Debian Perl Group.
Currently this is only a wrapper function for the L<dpt(1)> command, which
captures the output of L<dpt-checkout(1)> and changes the current directory to
the checkout.
captures the output of L<dpt-checkout(1)> and L<dpt-cd(1)> commands and changes
the current directory to the checkout.
=head1 OPTIONS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment