format_subcommand.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_DRIVER_FORMAT_SUBCOMMAND_H_
  5. #define CARBON_TOOLCHAIN_DRIVER_FORMAT_SUBCOMMAND_H_
  6. #include "common/command_line.h"
  7. #include "toolchain/driver/driver_env.h"
  8. #include "toolchain/driver/driver_subcommand.h"
  9. namespace Carbon {
  10. // Options for the format subcommand.
  11. //
  12. // See the implementation of `Build` for documentation on members.
  13. struct FormatOptions {
  14. auto Build(CommandLine::CommandBuilder& b) -> void;
  15. llvm::StringRef output_filename;
  16. llvm::SmallVector<llvm::StringRef> input_filenames;
  17. };
  18. // Implements the format subcommand of the driver.
  19. class FormatSubcommand : public DriverSubcommand {
  20. public:
  21. explicit FormatSubcommand();
  22. auto BuildOptions(CommandLine::CommandBuilder& b) -> void override {
  23. options_.Build(b);
  24. }
  25. auto Run(DriverEnv& driver_env) -> DriverResult override;
  26. private:
  27. FormatOptions options_;
  28. };
  29. } // namespace Carbon
  30. #endif // CARBON_TOOLCHAIN_DRIVER_FORMAT_SUBCOMMAND_H_