Author: Owen Pan
Date: 2024-12-09T00:56:24-08:00
New Revision: 411df3bb4941318a02a59b4cd7a898d4f9b788a3

URL: 
https://github.com/llvm/llvm-project/commit/411df3bb4941318a02a59b4cd7a898d4f9b788a3
DIFF: 
https://github.com/llvm/llvm-project/commit/411df3bb4941318a02a59b4cd7a898d4f9b788a3.diff

LOG: [clang-format] Make command lines of dump_format_[style|help].py consistent

Added: 
    

Modified: 
    clang/docs/tools/dump_format_style.py
    clang/test/Format/docs_updated.test

Removed: 
    


################################################################################
diff  --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index c98f2bdcb4f2f0..f00f3ee8b20e87 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -3,6 +3,7 @@
 # documentation in ../ClangFormatStyleOptions.rst automatically.
 # Run from the directory in which this file is located to update the docs.
 
+import argparse
 import inspect
 import os
 import re
@@ -474,6 +475,10 @@ class State:
         return options
 
 
+p = argparse.ArgumentParser()
+p.add_argument("-o", "--output", help="path of output file")
+args = p.parse_args()
+
 with open(FORMAT_STYLE_FILE) as f:
     opts = OptionsReader(f).read_options()
 with open(INCLUDE_STYLE_FILE) as f:
@@ -487,6 +492,5 @@ class State:
 
 contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
 
-output_file_path = sys.argv[1] if len(sys.argv) == 2 else DOC_FILE
-with open(output_file_path, "wb") as output:
+with open(args.output if args.output else DOC_FILE, "wb") as output:
     output.write(contents.encode())

diff  --git a/clang/test/Format/docs_updated.test 
b/clang/test/Format/docs_updated.test
index 56ca4d13eb375c..17066650a12677 100644
--- a/clang/test/Format/docs_updated.test
+++ b/clang/test/Format/docs_updated.test
@@ -1,4 +1,4 @@
-// RUN: %python %S/../../docs/tools/dump_format_style.py %t.style
+// RUN: %python %S/../../docs/tools/dump_format_style.py -o %t.style
 // RUN: 
diff  %t.style %S/../../docs/ClangFormatStyleOptions.rst
 
 // RUN: %python %S/../../docs/tools/dump_format_help.py -o %t.help


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to