| 268 | } |
| 269 | |
| 270 | int main(int argc, char** argv) { |
| 271 | format::FormatOptions opts; |
| 272 | bool is_tests = false; |
| 273 | TextPrinter tp; |
| 274 | vector<string> files; |
| 275 | if (argc < 2) { |
| 276 | tp << help(); |
| 277 | return -1; |
| 278 | } |
| 279 | for (int i = 1; i < argc; i++) { |
| 280 | const string arg = argv[i]; |
| 281 | if (arg.front() != '-') { |
| 282 | files.emplace_back(arg); |
| 283 | } else { |
| 284 | if (arg == "--tests") { |
| 285 | is_tests = true; |
| 286 | } else if (arg == "-i" || arg == "--inplace") { |
| 287 | opts.insert(format::FormatOpt::Inplace); |
| 288 | } else if (arg == "-v2" || arg == "--v2") { |
| 289 | opts.insert(format::FormatOpt::V2Syntax); |
| 290 | } else if (arg == "--semicolon") { |
| 291 | opts.insert(format::FormatOpt::SemicolonEOL); |
| 292 | } else { |
| 293 | tp << help(); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | if (!is_tests && files.empty()) { |
| 298 | tp << "no files" << "\n"; |
| 299 | } |
| 300 | InitModules(); |
| 301 | int rc; |
| 302 | if (is_tests) { |
| 303 | rc = test(); |
| 304 | } else { |
| 305 | rc = das::format::run(opts, files); |
| 306 | } |
| 307 | Module::Shutdown(); |
| 308 | return rc; |
| 309 | } |