改进程序入口
This commit is contained in:
parent
e50acdebb7
commit
764e1bbb82
|
@ -2,31 +2,12 @@
|
||||||
open HtmlStruct.Content
|
open HtmlStruct.Content
|
||||||
open System.Xml
|
open System.Xml
|
||||||
open HtmlStruct.Assemble
|
open HtmlStruct.Assemble
|
||||||
open HtmlStruct.Content
|
|
||||||
open HtmlStruct.Present
|
open HtmlStruct.Present
|
||||||
open System.IO
|
open System.IO
|
||||||
open System.Text
|
|
||||||
open System
|
open System
|
||||||
open System.Diagnostics
|
open System.Diagnostics
|
||||||
|
|
||||||
let args = System.Environment.GetCommandLineArgs()|> Array.toList
|
let html_generate (file_in:FileInfo) (dir_o:DirectoryInfo) =
|
||||||
|
|
||||||
if args.Length = 2 && args.Item(1) = "--help" then
|
|
||||||
System.Console.WriteLine("AstConv.exe -file xast文件路径 -odir 输出文件夹路径")
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
if args.Length <> 5 then
|
|
||||||
failwith "程序调用参数错误:AstConv.exe -file xast文件路径 -odir 输出文件夹路径"
|
|
||||||
|
|
||||||
let file_in, dir_o = match args.Item(1), args.Item(3) with
|
|
||||||
| "-file","-odir" ->
|
|
||||||
if not(FileInfo(args.Item 2).Exists) then
|
|
||||||
failwith "指定xast文件不存在"
|
|
||||||
if not(DirectoryInfo(args.Item 4).Exists) then
|
|
||||||
failwith "指定输出文件夹不存在"
|
|
||||||
FileInfo(args.Item 2), DirectoryInfo(args.Item 4)
|
|
||||||
| _ -> failwith "程序调用参数错误:AstConv.exe -file xast文件路径 -odir 输出文件夹路径"
|
|
||||||
|
|
||||||
let out_dir = Uri(dir_o.FullName)
|
let out_dir = Uri(dir_o.FullName)
|
||||||
|
|
||||||
let doc = XmlDocument()
|
let doc = XmlDocument()
|
||||||
|
@ -77,3 +58,37 @@ let stream2 = new StreamWriter(Path.Combine(dir_o.FullName, "volume_display.dot"
|
||||||
stream2.Write(graph2_code)
|
stream2.Write(graph2_code)
|
||||||
stream2.Flush()
|
stream2.Flush()
|
||||||
Process.Start("dot", $"""-Tsvg -o{Path.Combine(dir_o.FullName, "volume_display.svg")} {Path.Combine(dir_o.FullName, "volume_display.dot")}""") |> ignore
|
Process.Start("dot", $"""-Tsvg -o{Path.Combine(dir_o.FullName, "volume_display.svg")} {Path.Combine(dir_o.FullName, "volume_display.dot")}""") |> ignore
|
||||||
|
|
||||||
|
let args = System.Environment.GetCommandLineArgs()|> Array.toList
|
||||||
|
|
||||||
|
|
||||||
|
// 参数校验
|
||||||
|
match args.Length with
|
||||||
|
| 2 when args.Item(1) = "--help" ->
|
||||||
|
printfn "AstConv.exe --file xast文件路径 --html 输出文件夹路径\n\t构建HTML透视文档。"
|
||||||
|
printfn "AstConv.exe --file xast文件路径 --format\n\t格式化所有源文件。"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
// 格式化
|
||||||
|
| 4 when args.Item(1) = "--file" && args.Item(3) = "--format" ->
|
||||||
|
printfn "开发中"
|
||||||
|
|
||||||
|
// html生成
|
||||||
|
| 5 when args.Item(1) = "--file" && args.Item(3) = "--html" ->
|
||||||
|
if not(FileInfo(args.Item 2).Exists) then
|
||||||
|
printfn "Arguments-Error:指定xast文件不存在"
|
||||||
|
exit 0
|
||||||
|
if not(DirectoryInfo(args.Item 4).Exists) then
|
||||||
|
printfn "Arguments-Error:指定输出文件夹不存在"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
let xfile, xdir = FileInfo(args.Item 2), DirectoryInfo(args.Item 4)
|
||||||
|
// 构建html页面
|
||||||
|
html_generate xfile xdir
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
| _ ->
|
||||||
|
printfn "命令调用格式错误:"
|
||||||
|
printfn "AstConv.exe --file xast文件路径 --html 输出文件夹路径\n\t构建HTML透视文档。"
|
||||||
|
printfn "AstConv.exe --file xast文件路径 --format\n\t格式化所有源文件。"
|
||||||
|
exit 0
|
Loading…
Reference in New Issue