Skip to content

Commit

Permalink
feat: add DEBUG support
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaringe committed Mar 1, 2024
1 parent 5acd26b commit 6cf2785
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub fn serialization_identity_test() {
}
```

You can set `DEBUG=1` to get verbose output during codegen.

## todo

- [ ] complete all cases
Expand Down
3 changes: 2 additions & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "gserde"
version = "1.0.4"
version = "1.1.0"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
Expand All @@ -22,6 +22,7 @@ glance = "~> 0.8"
simplifile = "~> 1.2"
fswalk = "~> 2.0"
shellout = "~> 1.5"
dot_env = "~> 0.2"

[dev-dependencies]
gleeunit = "~> 1.0"
Expand Down
12 changes: 7 additions & 5 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
# You typically do not need to edit this file

packages = [
{ name = "fswalk", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_community_path", "gleam_stdlib", "simplifile"], otp_app = "fswalk", source = "hex", outer_checksum = "50C250FA4CF97D6C383ECF69D7446EFB9D4F8261328A13099478AAAD0CEDC081" },
{ name = "glance", version = "0.8.2", build_tools = ["gleam"], requirements = ["glexer", "gleam_stdlib"], otp_app = "glance", source = "hex", outer_checksum = "ACF09457E8B564AD7A0D823DAFDD326F58263C01ACB0D432A9BEFDEDD1DA8E73" },
{ name = "dot_env", version = "0.2.4", build_tools = ["gleam"], requirements = ["gleam_stdlib", "simplifile"], otp_app = "dot_env", source = "hex", outer_checksum = "FFAC6F89A2BB6896A10128E5850496C372821BFDB807C837A1404BEBDD1AB2B9" },
{ name = "fswalk", version = "2.0.2", build_tools = ["gleam"], requirements = ["dot_env", "gleam_stdlib", "gleam_community_path", "simplifile"], otp_app = "fswalk", source = "hex", outer_checksum = "5D8E9C34C4C1BF3E65A79A292FE98B4AD35E525D18BB068518359687FA7BD1EB" },
{ name = "glance", version = "0.8.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "ACF09457E8B564AD7A0D823DAFDD326F58263C01ACB0D432A9BEFDEDD1DA8E73" },
{ name = "gleam_community_path", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_path", source = "hex", outer_checksum = "916C2829E2ED81036BBA180CFD5E8633D05E25C304FDF6E3BC8A048459B89725" },
{ name = "gleam_json", version = "1.0.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "8B197DD5D578EA6AC2C0D4BDC634C71A5BCA8E7DB5F47091C263ECB411A60DF3" },
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
{ name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
{ name = "glexer", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "4484942A465482A0A100936E1E5F12314DB4B5AC0D87575A7B9E9062090B96BE" },
{ name = "shellout", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "7B5DE499DBB3DDC25051FC1BB3770DD5466938B6A2AFA91A6FB4A4D49F4CB0D4" },
{ name = "simplifile", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "AAFCF154F69B237D269FF2764890F61ABC4A7EF2A592D44D67627B99694539D9" },
{ name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
{ name = "simplifile", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "EB9AA8E65E5C1E3E0FDCFC81BC363FD433CB122D7D062750FFDF24DE4AC40116" },
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
]

[requirements]
dot_env = { version = "~> 0.2" }
fswalk = { version = "~> 2.0" }
glance = { version = "~> 0.8" }
gleam_json = { version = ">= 0.0.0 and < 2.0.0" }
Expand Down
17 changes: 15 additions & 2 deletions src/gserde.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import gleam/string
import gleam/result
import glance
import internal/serializer
import dot_env/env
import internal/deserializer
import simplifile
import request.{type Request, Request}
Expand Down Expand Up @@ -42,15 +43,27 @@ fn expect(x, msg) {
}

pub fn main() {
let is_debug = case env.get_bool("DEBUG") {
Ok(_) -> True
_ -> False
}
fswalk.builder()
|> fswalk.with_path("src")
|> fswalk.with_entry_filter(fswalk.only_files)
|> fswalk.walk
|> fswalk.map(fn(v) { expect(v, "failed to walk").filename })
|> fswalk.each(process_single)
|> fswalk.each(fn(f) { process_single(f, is_debug) })
}

pub fn process_single(src_filename: String) {
pub fn process_single(src_filename: String, is_debug) {
case is_debug {
True -> {
io.debug(#("Processing", src_filename))
Nil
}
_ -> Nil
}

let src_module_name =
src_filename
|> string.replace("src/", "")
Expand Down

0 comments on commit 6cf2785

Please sign in to comment.