Giter Club home page Giter Club logo

Comments (5)

casey avatar casey commented on July 30, 2024

I was thinking about just starting with something like:

# single line comments are allowed
# for now, the '#' must be the first non-whitespace character on a line

# simple recipes work as before:
foo:
  cd baz
  touch bar
  echo galf

# tabs and spaces can be mixed, but there must be an equal
# number of tabs and spaces (in whatever order) before
# every line in a recipe, so that a user's tab-width setting
# doesn't matter
#
# using . for space and - for tab:

# this is okay, every line starts with one space:
a:
.echo hello
.echo hello

# this is okay, every line starts with the same whitespace:
b:
.-echo hello
.-echo hello

# this is not okay, inconsistent whitespace:
c:
.-echo hello
--echo hello

# this is okay, because it is still unambiguous:
d:
.-echo hello
-.echo hello
# (we could disallow this)

# recipes may call other recipes
bar: foo a b
  echo "I'm bar!"

# as in make, a leading @ suppresses printing the command
qux:
  @echo "Pinging the server..."
  @ping 237.1.4.5

Constructing a DAG of recipes and detecting loops doesn't seem that hard.

@aoeu, thoughts?

from just.

casey avatar casey commented on July 30, 2024

Also, some kind of variable assignment is likely to be necessary. Makefiles allow setting the shell using SHELL := bash and it would be nice if justfiles still supported this.

from just.

casey avatar casey commented on July 30, 2024

Would it be too crazy to use a full scripting language outside of the recipes? Imagine if everything that wasn't a recipe was parsed and run as python, with a special syntax for exporting variables as environment variables to recipes?

If there were a good python implementation in rust, I think I would seriously consider it.

from just.

casey avatar casey commented on July 30, 2024

Okay, I just thought of a killer feature that we can provide if we move away from makefiles... If you add a shebang as the first line of a recipe, we run that recipe as a script instead:

stuff:
  #!/usr/bin/env python3
  def foo(a, b):
    print(a + b):
  for i in range(100):
    foo(i + i * i)

j will then extract the contents of the recipe, less the leading whitespace, and execute it as a script.

You could also use a shell shebang, if you use a lot of variables or want to continue in the case of command failure:

stuff:
  #!/bin/sh
  # variables will work as expected:
  A=hello
  echo getting $A...
  # the next line can fail and we'll still continue:
  curl http://example.com/$A > hello.html
  echo "We tried!"

from just.

casey avatar casey commented on July 30, 2024

Make is gone! Support for #! recipes is also in

from just.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.