diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-02-13 21:13:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 21:13:57 +0000 |
commit | 1be73ee8d2206a7f1520257d81c8a5a4f3cc195e (patch) | |
tree | c18785b9eac4612277ab70be164476ebd95a7303 /src/lustre.gleam | |
parent | 7960593c4feee21b65171afa220c2b32b43dd788 (diff) | |
download | lustre-1be73ee8d2206a7f1520257d81c8a5a4f3cc195e.tar.gz lustre-1be73ee8d2206a7f1520257d81c8a5a4f3cc195e.zip |
🚧 Begin working on CLI things. (#45)
* :recycle: Rename http ffi to lustre_try_ffi.
* :wrench: Add any files under lustre/cli as internal modules.
* :recyle: Move lustre/try command into cli subdirectory.
* :heavy_plus_sign: Add justin, simplifile, and tom as dependencies.
* :sparkles: Write a 'lustre add' command for downloading esbuild.
* :construction: Begin work on a 'lustre build' command for bundling apps and components.
* :sparkles: Add 'main' function as CLI entrypoint to lustre.
* :bug: Fix `no-styles` flag's name
* :bug: Use consistent path for error reporting in lustre add
* :construction: Project module
* :truck: Move esbuild functions to their own module
* :construction: Use a temporary file to bundle components
* :construction: Build app and update to glint rc
* :heavy_plus_sign: Add filepath dependency
* :bug: Fix wrong paths in esbuild code
---------
Co-authored-by: Giacomo Cavalieri <giacomo.cavalieri@icloud.com>
Diffstat (limited to 'src/lustre.gleam')
-rw-r--r-- | src/lustre.gleam | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/lustre.gleam b/src/lustre.gleam index 3151a1a..7aeb6b4 100644 --- a/src/lustre.gleam +++ b/src/lustre.gleam @@ -158,16 +158,45 @@ // IMPORTS --------------------------------------------------------------------- +import argv import gleam/bool import gleam/dict.{type Dict} -import gleam/dynamic.{type Decoder} +import gleam/dynamic.{type Decoder, type Dynamic} import gleam/erlang/process.{type Subject} import gleam/otp/actor.{type StartError} import gleam/result +import glint +import lustre/cli/add +import lustre/cli/build +import lustre/cli/try import lustre/effect.{type Effect} import lustre/element.{type Element, type Patch} import lustre/internals/runtime +// MAIN ------------------------------------------------------------------------ + +/// This function exists so you can run helpful Lustre utilities from the command +/// line using `gleam run -m lustre`. For a proper help message run: +/// +/// ```sh +/// gleam run -m lustre -- --help +/// ``` +/// +/// 🚨 If you're just using Lustre as a library, *you can ignore this function*. +/// +pub fn main() { + let args = argv.load().arguments + + glint.new() + |> glint.as_gleam_module + |> glint.with_name("lustre") + |> glint.add(at: ["add", "esbuild"], do: add.esbuild()) + |> glint.add(at: ["build", "app"], do: build.app()) + |> glint.add(at: ["build", "component"], do: build.component()) + |> glint.add(at: ["try"], do: try.run()) + |> glint.run(args) +} + // TYPES ----------------------------------------------------------------------- /// Represents a constructed Lustre application that is ready to be started. |