Skip to content

Make duckscript an alternate main language #1275

@daniel-pfeiffer

Description

@daniel-pfeiffer

I almost did your great product injustice, because TOML is no programming language – just cumbersome and hard to read! I found the same sentiment expressed on Reddit. That’s a pity, as I almost missed out.

Then I discovered duckscript, which is really quite nice! (Just a few things: the set command doesn’t set anything – a better name would be: one, pass, scalar, simple, single, value… And be consistent with double-hyphens: --encode/--decode at least optionally!)

As a coauthor of makepp I had quite some similar thoughts, e.g. I also provided the most important Shell commands and options as builtins.

As duckscript is builtin anyway, it would be cool to make it a 1st class citizen, rather than a shadow life embedded in strings. You might provide the option of Makefile.ds as an alternate language. Maybe we can do this together? As a suggestion for a few needed commands, I’ve translated some of your examples. A task would be similar to a function, but with optional metadata commands (dependencies, description…) to be extracted while defining it:

!wget -O company-makefile.ds https://company.com/makefile.ds
# choose language by suffix, either TOML or duckscript
!include_files ./company-makefile.ds

# builtin runner: imperatively run unconditionally before any tasks
cargo clean

task hello-world
    echo "Hello World From Unknown"
end

# task with alias
task hello-world.linux hello-world.mac
    echo "Hello World From Outside Windows"
end


task format
    description What this is about
    install_crate rustfmt
    cargo fmt -- --emit=files
end

### doc comment, same as description inside
task build
    cargo build
end

task test
    cargo test
end

task my-flow default
    # more a declaration than a command
    dependencies format build test
end

task cargo-script
    env CARGO_MAKE_RUST_SCRIPT_PROVIDER cargo-script
    script @rust # strip 1st line’s indentation on all lines
        fn main() {
            println!("test");
        }
    end
end

# or, even simpler
task cargo-play
    script @cargo-play
        fn main() {
            println!("test");
        }
    end
end

task sh
    script - sh # - instead of suffix means pipe it in without tempfile
        echo "Hello, World!"
    end
end

task python
    script py python
        print("Hello, World!")
    end
end

task php-with-args
    script php php -f
        <?php
            echo "Hello, World!\n";
        ?>
    end
end

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions