From fc0a86c038f54d90c34da63bcf7a6750e8092b72 Mon Sep 17 00:00:00 2001 From: JoshBrudnak Date: Thu, 9 Aug 2018 17:26:04 -0400 Subject: Add rustfmt command to devenv commands --- python/servo/devenv_commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/servo/devenv_commands.py') 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()) -- cgit v1.2.3