diff options
Diffstat (limited to 'python/servo/devenv_commands.py')
-rw-r--r-- | python/servo/devenv_commands.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index c6a3f8527ba..c61a5f781e5 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -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()) |