diff --git a/README.md b/README.md index 60ba49f..eb058fa 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,22 @@ All with a familiar and easy to learn syntax. Interested? Lets take a closer loo ##How to use scfg -First of all, go to my [github releases page](https://github.com/hugomg/scfgc/releases) to download the executable for the scfg compiler. +First of all, go to my [github releases page](https://github.com/hugomg/scfgc/releases) to download the executable for the scfg compiler. The zip should include two files, scfg.exe and scfg.bat -In Windows explorer, drag your scfg source file on top of the icon for the scfgc.exe executable. -scfg will convert that scfg file into a cfg file of the same name and place it next to the scfg source file. +If you know how to use the command line you can call scfg.exe directly. +Run `scfgc.exe --help` for usage isntructions. + +If you don't know how to use the command line you can use scfgc from Windows Explorer. +First, create a scfg script with the ".scfg" file extension. You can find some example files +[here](https://github.com/hugomg/scfgc/tree/master/examples). +Then, in the Windows Explorer window, drag the icon for the scfg file and drop it on top of the icon for the scfg.bat file. (Droping on top of scfg.exe also works, but won't show any error messages if a problem occurs). +If everything goes right, scfgc should convert your scfg file into a cfg file of the same name and place it next to the scfg source file. You can then add a line on your autoexec.cfg file to call your script when Dota2 starts up. For more complex scripts, scfg might not be able to compile your scfg file into a single cfg file. In these cases, it will also generate a folder with the same base name as your scfg file, containing helper files for your script. -Alternatively, you can invoke scfgc from the command line. Run `scfgc.exe --help` for usage instructions. - ##Commands A command consists of a command name followed by zero or more arguments. The argument list extends diff --git a/main.ml b/main.ml index afef57a..314be61 100644 --- a/main.ml +++ b/main.ml @@ -30,7 +30,8 @@ let skip_utf8_BOM chan = if not (n = bom_len && String.equal bom (Bytes.to_string buf)) then In_channel.seek chan orig_pos -let compile quiet in_filename = + +let compile in_filename = let exit_with_error errname pos errinfo = (match pos with @@ -41,13 +42,6 @@ let compile quiet in_filename = | None -> () | Some s -> fprintf stderr ": %s" s); fprintf stderr "\n"; - if not quiet then ( - (* Windows Explorer closes scfgc's terminal window, hiding errors, - * unless we prompt the user for input. *) - fprintf stderr "Press ENTER to continue:"; - Out_channel.flush stderr; - ignore @@ In_channel.input_byte stdin - ); exit 1 in @@ -128,11 +122,6 @@ let compile quiet in_filename = (* ----- *) open Cmdliner -let quiet = - let doc = "Skip the \"Press any key to continue\" prompt if there is an error. \ - Use this option if you are running scfgc from the command line." in - Arg.(value @@ flag @@ info ["q"; "quiet"] ~doc ~docv:"quiet") - let filename = let doc = "Source .scfg file" in Arg.(required @@ pos 0 (some @@ file) None @@ info [] ~doc ~docv:"filename") @@ -148,12 +137,10 @@ let cmd = `P "Send bugs and suggestions to https://github.com/hugomg/scfgc"; ] in Term.( - pure compile $ quiet $ filename, - info "scfgc" ~version:"0.2" ~doc ~man) + pure compile $ filename, + info "scfgc" ~version:"0.3" ~doc ~man) let () = match Term.eval cmd with | `Version | `Help | `Ok _ -> exit 0 | `Error _ -> exit 1 - - diff --git a/scfgc.bat b/scfgc.bat new file mode 100644 index 0000000..29abd31 --- /dev/null +++ b/scfgc.bat @@ -0,0 +1,3 @@ +@echo off +scfgc.exe %* +if errorlevel 1 pause