SCRIPT: wpiformat

This commit is contained in:
PJ Reiniger
2025-11-07 20:01:58 -05:00
committed by Peter Johnson
parent ae6bdc9d25
commit 2109161534
749 changed files with 5504 additions and 3936 deletions

View File

@@ -37,9 +37,9 @@ CommandPtr::CommandPtr(CommandPtr&& rhs) {
void CommandPtr::AssertValid() const {
if (!m_ptr) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Moved-from CommandPtr object used!\nMoved out at:\n{}",
m_moveOutSite);
throw WPILIB_MakeError(
wpi::err::CommandIllegalUse,
"Moved-from CommandPtr object used!\nMoved out at:\n{}", m_moveOutSite);
}
}

View File

@@ -285,7 +285,7 @@ void CommandScheduler::SetDefaultCommand(Subsystem* subsystem,
CommandPtr&& defaultCommand) {
if (!defaultCommand.get()->HasRequirement(subsystem)) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse, "{}",
"Default commands must require their subsystem!");
"Default commands must require their subsystem!");
}
RequireUngrouped(defaultCommand.get());
@@ -430,11 +430,12 @@ void CommandScheduler::OnCommandFinish(Action action) {
void CommandScheduler::RequireUngrouped(const Command* command) {
auto stacktrace = command->GetPreviousCompositionSite();
if (stacktrace.has_value()) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands that have been composed may not be added to "
"another composition or scheduled individually!"
"\nOriginally composed at:\n{}",
stacktrace.value());
throw WPILIB_MakeError(
wpi::err::CommandIllegalUse,
"Commands that have been composed may not be added to "
"another composition or scheduled individually!"
"\nOriginally composed at:\n{}",
stacktrace.value());
}
}
@@ -455,8 +456,8 @@ void CommandScheduler::RequireUngrouped(
void CommandScheduler::RequireUngroupedAndUnscheduled(const Command* command) {
if (IsScheduled(command)) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands that have been scheduled individually may "
"not be added to another composition!");
"Commands that have been scheduled individually may "
"not be added to another composition!");
}
RequireUngrouped(command);
}

View File

@@ -83,7 +83,8 @@ CommandPtr cmd::DeferredProxy(wpi::util::unique_function<Command*()> supplier) {
{});
}
CommandPtr cmd::DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier) {
CommandPtr cmd::DeferredProxy(
wpi::util::unique_function<CommandPtr()> supplier) {
return Defer([supplier = std::move(
supplier)]() mutable { return supplier().AsProxy(); },
{});

View File

@@ -11,8 +11,9 @@
using namespace wpi::cmd;
DeferredCommand::DeferredCommand(wpi::util::unique_function<CommandPtr()> supplier,
Requirements requirements)
DeferredCommand::DeferredCommand(
wpi::util::unique_function<CommandPtr()> supplier,
Requirements requirements)
: m_supplier{std::move(supplier)} {
AddRequirements(requirements);
}

View File

@@ -70,8 +70,8 @@ void ParallelCommandGroup::AddCommands(
if (isRunning) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands cannot be added to a CommandGroup "
"while the group is running");
"Commands cannot be added to a CommandGroup "
"while the group is running");
}
for (auto&& command : commands) {
@@ -86,8 +86,8 @@ void ParallelCommandGroup::AddCommands(
m_commands.emplace_back(std::move(command), false);
} else {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Multiple commands in a parallel group cannot "
"require the same subsystems");
"Multiple commands in a parallel group cannot "
"require the same subsystems");
}
}
}

View File

@@ -70,8 +70,8 @@ void ParallelDeadlineGroup::AddCommands(
if (!m_finished) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands cannot be added to a CommandGroup "
"while the group is running");
"Commands cannot be added to a CommandGroup "
"while the group is running");
}
for (auto&& command : commands) {
@@ -86,8 +86,8 @@ void ParallelDeadlineGroup::AddCommands(
m_commands.emplace_back(std::move(command), false);
} else {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Multiple commands in a parallel group cannot "
"require the same subsystems");
"Multiple commands in a parallel group cannot "
"require the same subsystems");
}
}
}

View File

@@ -57,8 +57,8 @@ void ParallelRaceGroup::AddCommands(
if (isRunning) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands cannot be added to a CommandGroup "
"while the group is running");
"Commands cannot be added to a CommandGroup "
"while the group is running");
}
for (auto&& command : commands) {
@@ -73,8 +73,8 @@ void ParallelRaceGroup::AddCommands(
m_commands.emplace_back(std::move(command));
} else {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Multiple commands in a parallel group cannot "
"require the same subsystems");
"Multiple commands in a parallel group cannot "
"require the same subsystems");
}
}
}

View File

@@ -11,8 +11,9 @@
using namespace wpi::cmd;
PrintCommand::PrintCommand(std::string_view message)
: CommandHelper{[str = std::string(message)] { wpi::util::print("{}\n", str); },
{}} {}
: CommandHelper{
[str = std::string(message)] { wpi::util::print("{}\n", str); },
{}} {}
bool PrintCommand::RunsWhenDisabled() const {
return true;

View File

@@ -69,8 +69,8 @@ void SequentialCommandGroup::AddCommands(
if (m_currentCommandIndex != invalid_index) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Commands cannot be added to a CommandGroup "
"while the group is running");
"Commands cannot be added to a CommandGroup "
"while the group is running");
}
for (auto&& command : commands) {

View File

@@ -13,16 +13,18 @@ NetworkButton::NetworkButton(wpi::nt::BooleanTopic topic)
: NetworkButton(topic.Subscribe(false)) {}
NetworkButton::NetworkButton(wpi::nt::BooleanSubscriber sub)
: Trigger([sub = std::make_shared<wpi::nt::BooleanSubscriber>(std::move(sub))] {
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
}) {}
: Trigger(
[sub = std::make_shared<wpi::nt::BooleanSubscriber>(std::move(sub))] {
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
}) {}
NetworkButton::NetworkButton(std::shared_ptr<wpi::nt::NetworkTable> table,
std::string_view field)
: NetworkButton(table->GetBooleanTopic(field)) {}
NetworkButton::NetworkButton(std::string_view table, std::string_view field)
: NetworkButton(wpi::nt::NetworkTableInstance::GetDefault(), table, field) {}
: NetworkButton(wpi::nt::NetworkTableInstance::GetDefault(), table, field) {
}
NetworkButton::NetworkButton(wpi::nt::NetworkTableInstance inst,
std::string_view table, std::string_view field)

View File

@@ -37,7 +37,8 @@ namespace wpi::cmd {
* @see CommandScheduler
* @see CommandHelper
*/
class Command : public wpi::util::Sendable, public wpi::util::SendableHelper<Command> {
class Command : public wpi::util::Sendable,
public wpi::util::SendableHelper<Command> {
public:
~Command() override;

View File

@@ -34,8 +34,9 @@ class Subsystem;
*
* This class is provided by the NewCommands VendorDep
*/
class CommandScheduler final : public wpi::util::Sendable,
public wpi::util::SendableHelper<CommandScheduler> {
class CommandScheduler final
: public wpi::util::Sendable,
public wpi::util::SendableHelper<CommandScheduler> {
public:
/**
* Returns the Scheduler instance.
@@ -213,7 +214,7 @@ class CommandScheduler final : public wpi::util::Sendable,
void SetDefaultCommand(Subsystem* subsystem, T&& defaultCommand) {
if (!defaultCommand.HasRequirement(subsystem)) {
throw WPILIB_MakeError(wpi::err::CommandIllegalUse,
"Default commands must require their subsystem!");
"Default commands must require their subsystem!");
}
SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
std::forward<T>(defaultCommand)));

View File

@@ -16,8 +16,8 @@
namespace wpi::cmd::sysid {
using ramp_rate_t = wpi::units::unit_t<
wpi::units::compound_unit<wpi::units::volt, wpi::units::inverse<wpi::units::second>>>;
using ramp_rate_t = wpi::units::unit_t<wpi::units::compound_unit<
wpi::units::volt, wpi::units::inverse<wpi::units::second>>>;
/** Hardware-independent configuration for a SysId test routine. */
class Config {