改进程序入口

This commit is contained in:
codeboss 2025-04-04 19:10:08 +08:00
parent e50acdebb7
commit 764e1bbb82
1 changed files with 78 additions and 63 deletions

View File

@ -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\tHTML"
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\tHTML"
printfn "AstConv.exe --file xast文件路径 --format\n\t"
exit 0