~mrms/fmtum

55078116375747e99366b06e1d7d0ef7cf751bbd — Marek Ma┼íkarinec 2 months ago d77ea46
Update umka version

Signed-off-by: Marek Maškarinec <marek@mrms.cz>
3 files changed, 21 insertions(+), 26 deletions(-)

M .build.yml
R pak.json => box.json
M fmt.um
M .build.yml => .build.yml +13 -16
@@ 1,27 1,24 @@
image: debian/bullseye
packages:
- python3
- python3-pip
- curl
- mingw-w64
- unzip
secrets:
- 1d3c187b-0f00-4efa-91df-b9523c3a2db5
sources:
- https://git.sr.ht/~mrms/fmtum
- https://git.sr.ht/~mrms/pak
environment:
  project: fmt
secrets:
- ed722dc4-1829-4784-bcc1-381c880a854f
shell: false
    NAME: fmtum
tasks:
- setup: |
    cd pak
    python3 -m pip install -r requirements.txt
    ./setup.py install --user
    curl https://mrms.cz/dl/umbox/umbox_portable.zip -O
    unzip umbox_portable.zip
- build: |
    cd fmtum
    python3 -m pak update
    python3 -m pak build
    cd $NAME
    ../umbox_portable/umbox update
    ../umbox_portable/umbox build
- deploy: |
    cd fmtum
    cd $NAME
    set +x
    python3 -m pak upload -t `cat ../.secret` pak.tar
    python3 -m pak upload -t `cat ../.secret` pak.json
    ../umbox_portable/umbox upload `cat ../.secret` box.tar
    set -x

R pak.json => box.json +1 -3
@@ 7,7 7,5 @@
    "readme": "README.md",
    "link": "",
    "dependencies": [],
    "include": ["fmt.um"],
    "run_posix": "./pak/umka/linux/umka fmt.um",
    "run_windows": ".\\pak\\umka\\windows\\umka.exe fmt.um"
    "include": ["fmt.um"]
}

M fmt.um => fmt.um +7 -7
@@ 4,7 4,7 @@ import (

//~~fn fmt
// "{}" in the string `s` will be subtituted for the arguments
fn fmt*(s: str, args: ..any): str {
fn fmt*(s: str, args: ..any): (str, std::Err) {
//~~
	o := []char{}
	a := 0


@@ 25,7 25,7 @@ fn fmt*(s: str, args: ..any): str {
		}

		if a >= len(args) {
			error("sfmt: not enough arguments")
			return "", std.error(-1, "not enough arguments", "fmt.um")
		}

		o = append(o, []char(sprintf("%v", args[a])))


@@ 36,10 36,10 @@ fn fmt*(s: str, args: ..any): str {
	}

	if a != len(args) {
		error("sfmt: too many arguments")
		return "", std.error(-1, "too many arguments", "fmt.um")
	}

	return o
	return o, {}
}

type vec2 = struct {


@@ 47,8 47,8 @@ type vec2 = struct {
}

fn main() {
	printf("basic usage: %s\n", fmt("a number {}, a string {}", 32, "hello"))
	printf("skip format tag: %s\n", fmt("skip me \\{}"))
	printf("complex types: %s\n", fmt("what can this print? {} {}",
	printf("basic usage: %v\n", fmt("a number {}, a string {}", 32, "hello"))
	printf("skip format tag: %v\n", fmt("skip me \\{}"))
	printf("complex types: %v\n", fmt("what can this print? {} {}",
		vec2{2, 4}, []int{1, 2, 3, 4}))
}