#include "../subcommand/tag_subcommand.hpp"
#include
tag_subcommand::tag_subcommand(const libgit2_object&, CLI::App& app)
{
auto* sub = app.add_subcommand("tag", "Create, list, delete or verify tags");
sub->add_flag("-l,--list", m_list_flag, "List tags. With optional .");
sub->add_flag("-f,--force", m_force_flag, "Replace an existing tag with the given name (instead of failing)");
sub->add_option("-d,--delete", m_delete, "Delete existing tags with the given names.");
sub->add_option(
"-n",
m_num_lines,
" specifies how many lines from the annotation, if any, are printed when using -l. Implies --list."
);
sub->add_flag("-a,--annotate", m_annotate_flag, "Make an annotated tag.");
sub->add_option("-m,--message", m_message, "Tag message for annotated tags");
sub->add_option("", m_tag_name, "Tag name");
sub->add_option("", m_target, "Target commit (defaults to HEAD)");
sub->callback(
[this]()
{
this->run();
}
);
}
namespace
{
// Tag listing: Print individual message lines
void print_list_lines(const std::string& message, int num_lines)
{
if (message.empty())
{
return;
}
auto lines = split_input_at_newlines(message);
// header
std::cout