aboutsummaryrefslogtreecommitdiff
path: root/licentia/source/program/licentia.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-06-14 18:33:54 -0400
committerEduardo Julian2021-06-14 18:33:54 -0400
commit519c0c0c71cdf7ce3dfc64b9781ab826760b3d94 (patch)
tree75fa0672afceff129e5e75afb7a5fed197ce1773 /licentia/source/program/licentia.lux
parentaf3e6e2cb011dc2ad9204440990731a2f272716d (diff)
Extracted Licentia out of the standard library.
Diffstat (limited to 'licentia/source/program/licentia.lux')
-rw-r--r--licentia/source/program/licentia.lux85
1 files changed, 85 insertions, 0 deletions
diff --git a/licentia/source/program/licentia.lux b/licentia/source/program/licentia.lux
new file mode 100644
index 000000000..57ed832e5
--- /dev/null
+++ b/licentia/source/program/licentia.lux
@@ -0,0 +1,85 @@
+## The licenses produced by this program are inspired by:
+## Apache License (Version 2.0): https://www.apache.org/licenses/LICENSE-2.0
+## Mozilla Public License (Version 2.0): https://www.mozilla.org/en-US/MPL/2.0/
+## MIT/Expat License: https://opensource.org/licenses/MIT
+## BSD licenses: https://en.wikipedia.org/wiki/BSD_licenses
+## Commons Clause: https://commonsclause.com/
+## Reciprocal Public License 1.5 (RPL-1.5): https://opensource.org/licenses/RPL-1.5
+## The Parity Public License: https://licensezero.com/licenses/parity
+## The Charity Public License: https://licensezero.com/licenses/charity
+## Lerna black-list: https://github.com/lerna/lerna/pull/1616
+## Common Public Attribution License Version 1.0 (CPAL-1.0): https://opensource.org/licenses/CPAL-1.0
+## Eclipse Public License v2.0: https://www.eclipse.org/legal/epl-2.0/
+
+(.module:
+ [lux #*
+ [ffi (#+ import:)]
+ [program (#+ program:)]
+ ["." debug]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ [remember (#+ to_do)]
+ ["." io (#+ IO) ("#\." monad)]
+ ["." try (#+ Try)]
+ ["." parser
+ ["<.>" cli]
+ ["<.>" json]]
+ [security
+ ["!" capability]]]
+ [data
+ ["." maybe]
+ ["." text
+ ["%" format (#+ format)]
+ [encoding
+ ["." utf8]]]
+ [format
+ ["." json]]]
+ [world
+ ["." file (#+ Path File)]]]
+ ["." / #_
+ ["#." input]
+ ["#." output]])
+
+(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: (success_message output)
+ (-> Path Text)
+ (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))}]
+ (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 (\ utf8.codec decode blob)
+ json (|> raw_json
+ (:coerce java/lang/String)
+ java/lang/String::trim
+ (:coerce Text)
+ (\ json.codec decode))]
+ (|> 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) (\ utf8.codec encode document))))]
+ (wrap (debug.log! (case ?done
+ (#try.Success _)
+ (success_message output)
+
+ (#try.Failure message)
+ message)))))