Add rustfmt command to devenv commands

This commit is contained in:
JoshBrudnak 2018-08-09 17:26:04 -04:00
parent 0b35a67260
commit fc0a86c038

View file

@ -227,3 +227,16 @@ class MachCommands(CommandBase):
with cd(self.context.topdir):
return self.call_rustup_run(["cargo", "fetch"], env=self.build_env())
@Command('rustfmt',
description='Format the Rust code using Cargo fmt',
category='devenv')
@CommandArgument(
'--directory', '-d', default=None,
help='Command-line argument to specify the directory for formatting')
def rustfmt(self, directory=""):
if directory == "":
directory = self.context.topdir
with cd(self.context.topdir):
return self.call_rustup_run(["cargo", "fmt", "--", directory], env=self.build_env())