Giter Site home page Giter Site logo

ddanier / nur Goto Github PK

View Code? Open in Web Editor NEW
34.0 1.0 1.0 433 KB

nur - a taskrunner based on nu shell

Home Page: https://nur-taskrunner.github.io/docs/

License: Other

Rust 81.97% JavaScript 0.09% Nu 1.44% Nushell 13.36% Shell 3.15%
development development-tools nu nushell task-runner tasks rust

nur's Introduction

nur - a taskrunner based on nu shell

nur is a simple, yet very powerful task runner. It borrows ideas from b5 and just, but uses nu shell scripting to define the tasks. This allows for well-structured tasks while being able to use the super-powers of nu in your tasks.

Quick overview and example

nur allows you to execute tasks defined in a file called nurfile. It will look through your current working directory and all its parents to look for this file. When it has found the nurfile it will change to the directory the file was found in and then source the file into nu script. You can define tasks like this:

# Just tell anybody or the "world" hello
def "nur hello" [
    name: string = "world"  # The name to say hello to
] {
    print $"hello ($name)"
}

The important bit is that you define your tasks as subcommands for "nur". If you then execute nur hello it will print "hello world", meaning it did execute the task hello in your nurfile. You can also use nur --help to get some details on how to use nur and nur --help hello to see what this hello task accepts as parameters.

You may also pass arguments to your nur tasks, like using nur hello bob to pass "bob" as the name to the "hello" task. This supports all parameter variants normal nu scripts could also handle. You may use nur --help <task-name> to see the help for an available command.

Your tasks then can do whatever you want them to do in nu script. This allows for very structured usage of for example docker to run/manage your project needs. But it can also execute simple commands like you would normally do in your shell (like npm ci or something). nur is not tied to any programming language, packaging system or anything. As in the end the nurfile is basically a normal nu script you can put into this whatever you like.

I recommend reading working with nur to get an overview how to use nur. Also I recommend reading the nu documentation about custom commands for details on how to define nu commands (and nur tasks) and at least read through the nu quick tour to understand some basics and benefits about nu scripting.

Installing nur

You may use cargo to quickly install nur for your current user:

> cargo install nur

The nur binary will be added in $HOME/.cargo/bin (or $"($env.HOME)/.cargo/bin" in nu shell). Make sure to add this to $PATH (or $env.PATH in nu shell).

For more details see the nur installation docs. This also includes MacOS (using homebrew) and Windows (using .msi installer) installation methods.

Working with nur

nur uses a file called nurfile to define your tasks. This file is a normal nu script and may include any nur tasks defined as sub commands to "nur". nur tasks may use the normal nu command features to define required arguments, their types and more.

See the working with nur documentation for more details.

Switching to nur

Switching to nur on a large project or when having many projects can be some hassle. The recommended workflow is to create a nurfile that only calls the old task runner and then gradually convert your tasks to be rewritten as nur tasks.

To simplify this process you may use the script nurify to generate a nurfile from many existing task runners.

For more details see the switching to nur documentation.

Contributing

See the contributing documentation for more details.

nur's People

Contributors

bambamboole avatar ddanier avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bambamboole

nur's Issues

How to install ?

Hey mate, can we get some simple installation docs please ?

Ideally also for development ;)

Road to 0.2 - aka "first stable release"

I'm currently using version 0.1.x for trying out things and finding the best way to implement stuff. Version 0.2.0 should be the version that provides some stable ground to build upon and also contain all the core features. After 0.2.0 I will switch to a semver based release versioning.

Ideas I want to think about and/or implement for 0.2.0:

  • nur should not interfere with normal nu shell config/env. Thus maybe we should set default-config-dir to $project-path/.nur. This would also replace the current .nurscripts directory.
    • Seems not really possible, BUT: We can set libs and plugins dir accordingly
  • Refactor main.rs to be way more modular, should also increase testability.
  • Maybe provide nu_plugin_nur command to easily register nur as a nu plugin for nu shell users. See #3
  • Ensure we have the right base feature set. Maybe less is more here. See #1 and #2
  • Have at least some tests to ensure nur works from a user perspective, maybe actually call some nur tasks for this. Might include #6
  • nur was tested on Linux, Mac and Windows.
  • Provide binaries for the most common systems. See https://github.com/nushell/nushell/blob/main/.github/workflows/release.yml for how nu does this
  • Should it be possible to use plugins? Would be a local requirement - I don't really like that.
  • Which feature flags should be active? Follow nu? Do we really need dataframes?
  • Update docs to match current version. Document at least env.nu and scripts behaviour

The cwd for nur process could be $nur.run-path instead of $nur.project-path

Describe the bug
The cwd for nur process could be $nur.run-path instead of $nur.project-path
If I create new tmux pane from the pane which is used for running nur process, I can get the new pane whose pane cwd is $nur.run-path

To Reproduce

.
├── a
├── b
└── nurfile

When I run nur in a directory, the nur process cwd is $nur.project-path instead of $nur.run-path (In a directory)

Expected behavior

I prefer use $nur.run-path. So I can create new tmux pane from nur process pane without extra cd command.
Or make the behavior configurable

Add some tests

At least provide some example nurfiles we test against. :)

`which` not working on windows

Describe the bug
The which (nu built-in) commnad doesnt work on the windows version, while it does on the linux version.

To Reproduce
Steps to reproduce the behavior:

  1. Install latest [email protected]
  2. define a task
    def "nur w" [] { which which }
  3. Run the nur w task
  4. Notice that on windows the command fails with nu::shell::external_command

image

Expected behavior
The which command runs successfully and prints the following output

image

Version details (please complete the following information):

  • OS: windows
  • OS-Version: 11 (22631)
  • nur Version: 0.5.1

Additional context
N/A

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.