diff options
author | Eduardo Julian | 2021-06-14 18:33:54 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-06-14 18:33:54 -0400 |
commit | 519c0c0c71cdf7ce3dfc64b9781ab826760b3d94 (patch) | |
tree | 75fa0672afceff129e5e75afb7a5fed197ce1773 /stdlib/source/program/licentia.lux | |
parent | af3e6e2cb011dc2ad9204440990731a2f272716d (diff) |
Extracted Licentia out of the standard library.
Diffstat (limited to '')
-rw-r--r-- | licentia/source/program/licentia.lux (renamed from stdlib/source/program/licentia.lux) | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/stdlib/source/program/licentia.lux b/licentia/source/program/licentia.lux index 896f74dab..57ed832e5 100644 --- a/stdlib/source/program/licentia.lux +++ b/licentia/source/program/licentia.lux @@ -13,15 +13,17 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] + [program (#+ program:)] + ["." debug] [abstract [monad (#+ do)]] [control - [remember (#+ to-do)] + [remember (#+ to_do)] ["." io (#+ IO) ("#\." monad)] ["." try (#+ Try)] ["." parser - ["." cli (#+ program:)] + ["<.>" cli] ["<.>" json]] [security ["!" capability]]] @@ -29,7 +31,8 @@ ["." maybe] ["." text ["%" format (#+ format)] - ["." encoding]] + [encoding + ["." utf8]]] [format ["." json]]] [world @@ -38,32 +41,32 @@ ["#." input] ["#." output]]) -(with-expansions [<expiry> "2021-04-01"] - (to-do <expiry> "Replace _.work with _.covered-work or _.licensed-work") - (to-do <expiry> "Create a short notice to add as a comment to each file in the _.work")) +(with_expansions [<expiry> "2022-04-01"] + (to_do <expiry> "Replace _.work with _.covered_work or _.licensed_work") + (to_do <expiry> "Create a short notice to add as a comment to each file in the _.work")) (import: java/lang/String ["#::." (trim [] java/lang/String)]) -(def: default-output-file "LICENSE") +(def: default_output_file "LICENSE") -(def: (success-message output) +(def: (success_message output) (-> Path Text) - (format "Your license has been made!" text.new-line + (format "Your license has been made!" text.new_line "Check the file " output ".")) -(program: [{input (cli.named "--input" cli.any)} - {output (parser.default ..default-output-file - (cli.named "--output" cli.any))}] +(program: [{input (<cli>.named "--input" <cli>.any)} + {output (parser.default ..default_output_file + (<cli>.named "--output" <cli>.any))}] (do io.monad [?done (: (IO (Try Any)) (do (try.with io.monad) [file (!.use (\ file.default file) [input]) blob (!.use (\ file content) []) document (io\wrap (do {! try.monad} - [raw-json (\ encoding.utf8 decode blob) - json (|> raw-json + [raw_json (\ utf8.codec decode blob) + json (|> raw_json (:coerce java/lang/String) java/lang/String::trim (:coerce Text) @@ -71,12 +74,12 @@ (|> json (<json>.run /input.license) (\ ! map /output.license)))) - output-file (: (IO (Try (File IO))) - (file.get-file io.monad file.default output))] - (!.use (\ output-file over-write) (\ encoding.utf8 encode document))))] - (wrap (log! (case ?done - (#try.Success _) - (success-message output) + output_file (: (IO (Try (File IO))) + (file.get_file io.monad file.default output))] + (!.use (\ output_file over_write) (\ utf8.codec encode document))))] + (wrap (debug.log! (case ?done + (#try.Success _) + (success_message output) - (#try.Failure message) - message))))) + (#try.Failure message) + message))))) |