mu: add 'label' command + manpage + tests

Add a label command and document it.
This commit is contained in:
Dirk-Jan C. Binnema
2025-07-27 09:24:57 +03:00
parent 1e628dfcab
commit 46fa4f2aa2
11 changed files with 1510 additions and 18 deletions

View File

@ -20,12 +20,10 @@
#include "mu-labels.hh"
#include <set>
#include <algorithm>
using namespace Mu;
using namespace Mu::Labels;
Result<void>
Mu::Labels::validate_label(const std::string &label)
{
@ -55,19 +53,24 @@ Mu::Labels::validate_label(const std::string &label)
if (uc > ' ' && uc <= '~') {
switch (uc) {
case '"':
case ',':
case '/':
case '\\':
case '*':
case '$':
return Err(Error{Error::Code::InvalidArgument,
"illegal character '{}' in label ({})", uc, label});
"illegal character '{}' in label '{}'", uc, label});
default:
break;
}
} else
} else if (::isprint(uc))
return Err(Error{Error::Code::InvalidArgument,
"illegal non alpha-numeric character '{}' in label ({})",
uc, label});
"illegal non alpha-numeric character '{}' in label '{}'",
static_cast<char>(uc), label});
else
return Err(Error{Error::Code::InvalidArgument,
"illegal non alpha-numeric character {:#x} in label '{}'",
uc, label});
}
return Ok();
@ -156,7 +159,6 @@ Mu::Labels::updated_labels(const LabelVec& labels, const DeltaLabelVec& deltas)
static void
test_parse_delta_label()
{
{
const auto expr = parse_delta_label("+foo");
assert_valid_result(expr);
@ -164,7 +166,6 @@ test_parse_delta_label()
assert_equal(expr->second, "foo");
}
{
const auto expr = parse_delta_label("-bar@cuux");
assert_valid_result(expr);