% Copyright (C) 2007 Florian Weimer
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; see the file COPYING. If not, write to
% the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
% Boston, MA 02110-1301, USA.
\darcsCommand{show tags}
\begin{code}

moduleDarcs.Commands.ShowTags(showTags)whereimportDarcs.Arguments(DarcsFlag(..),workingRepoDir)importDarcs.Commands(DarcsCommand(..),nodefaults)importDarcs.Hopefully(info)importDarcs.Repository(amInRepository,readRepo,withRepository,($-))importDarcs.Patch.Info(piTag)importDarcs.Patch.Set(newset2RL)importDarcs.Witnesses.Ordered(mapRL)importSystem.IO(stderr,hPutStrLn)-- import Printer ( renderPS )showTagsDescription::StringshowTagsDescription="Show all tags in the repository."showTagsHelp::StringshowTagsHelp="The tags command writes a list of all tags in the repository to standard\n"++"output.\n"++"\n"++"Tab characters (ASCII character 9) in tag names are changed to spaces\n"++"for better interoperability with shell tools. A warning is printed if\n"++"this happens."showTags::DarcsCommandshowTags=DarcsCommand{commandProgramName="darcs",commandName="tags",commandHelp=showTagsHelp,commandDescription=showTagsDescription,commandExtraArgs=0,commandExtraArgHelp=[],commandCommand=tagsCmd,commandPrereq=amInRepository,commandGetArgPossibilities=return[],commandArgdefaults=nodefaults,commandAdvancedOptions=[],commandBasicOptions=[workingRepoDir]}tagsCmd::[DarcsFlag]->[String]->IO()tagsCmdopts_=withRepositoryopts$-\repository->dopatches<-readReporepositorysequence_$mapRLprocess$newset2RLpatcheswhereprocesshp=casepiTag$infohpofJustt->dot'<-normalizettFalseputStrLnt'Nothing->return()normalize::String->String->Bool->IOStringnormalize_[]_=return[]normalizet(x:xs)flag=ifx=='\t'thendoifflagthenreturn()elsehPutStrLnstderr("warning: tag with TAB character: "++t)rest<-(normalizetxsTrue)return$' ':restelsedorest<-(normalizetxsflag)return$x:rest