format_subcommand.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. static const CommandLine::CommandInfo Info;
  15. auto Build(CommandLine::CommandBuilder& b) -> void;
  16. llvm::StringRef output_filename;
  17. llvm::SmallVector<llvm::StringRef> input_filenames;
  18. };
  19. // Implements the format subcommand of the driver.
  20. class FormatSubcommand : public DriverSubcommand {
  21. public:
  22. auto BuildOptions(CommandLine::CommandBuilder& b) { options_.Build(b); }
  23. auto Run(DriverEnv& driver_env) -> DriverResult override;
  24. private:
  25. FormatOptions options_;
  26. };
  27. } // namespace Carbon
  28. #endif // CARBON_TOOLCHAIN_DRIVER_FORMAT_SUBCOMMAND_H_