Skip to content

Commit

Permalink
Rename to pls and add some more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
james-w committed Jul 12, 2024
1 parent 8ce8232 commit 45f2c29
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 179 deletions.
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "taskrunner"
name = "pls"
version = "0.1.0"
edition = "2021"

Expand Down
98 changes: 95 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Task Runner
# `pls` - A Task Runner

`pls` runs tasks; kind of like Make, but more modern.

## Features

Expand Down Expand Up @@ -42,6 +44,96 @@

* :fast_forward: Some way to flatten out to run the same commands in CI?

## Usage

Usage is driven by a file called `pls.toml`. Create this at the root of your project
(next to your `.git` directory), add add it to version control.

### Commands

The file describes a series of commands that you can run, like this:

```toml
[command.exec.hello]
command = "echo hello world"
```

This defines a command called `hello`, so we can run it with:

```console
$ pls run hello
[command.exec.hello] Running echo hello world
hello world
```

You can define a number of commands that do different things, and with different
arguments depending on your needs.

```toml
[command.exec.hello]
command = "echo hello world"

[command.exec.goodbye]
command = "echo goodbye"
```

#### Container commands

You can also specify commands that run inside containers using `podman`.

```toml
[command.container.hello]
image = 'docker.io/alpine:latest
command = echo hello
```
They can then be run in exactly the same way.
```console
$ pls run hello
[command.exec.hello] Running container using docker.io/alpine:latest
hello
```
This allows you to rely on specific versions of tools, or other cases
where using a container is preferable.
#### Arguments
#### Dependencies with `requires`
You can specify that one command needs to run after another by using
the `requires` configuration option.
```toml
[command.container.one]
image = 'docker.io/alpine:latest
command = echo one

[command.exec.two]
command = echo two
```

#### Reuse with `extends`

#### Variables

#### Long-running commands with daemons

#### Outputs

### Artifacts

#### Container Images

#### Timestamp comparisons

#### Last-run comparisons

#### Forcing a rebuild to happen

### Descriptions

## Detecting changes

When in watch mode you want a set of paths to trigger changes, with some excludes.
Expand Down Expand Up @@ -123,8 +215,8 @@ uses = "cargo_with_db"
args = "run"
```

`taskrunner run <COMMAND> [ARGS...]` to run a command or build an artifact
`pls run <COMMAND> [ARGS...]` to run a command or build an artifact
(with disambiguation). Provides the way to force a build to happen.

`taskrunner build <ARTIFACT>` to build an artifact, taking in to account
`pls build <ARTIFACT>` to build an artifact, taking in to account
whether deps have changed etc.
130 changes: 0 additions & 130 deletions TASKRUNNER.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl ExecArtifact {
}
}

pub const CONFIG_FILE_NAME: &str = "taskrunner.toml";
pub const CONFIG_FILE_NAME: &str = "pls.toml";

pub fn find_config_file() -> Option<std::path::PathBuf> {
let mut config_dir = std::env::current_dir().unwrap();
Expand Down
10 changes: 5 additions & 5 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,18 +616,18 @@ fn find_required(target: &TargetInfo, context: &Context) -> Result<Vec<Target>>
}

fn metadata_path(name: &str) -> Result<std::path::PathBuf> {
Ok(std::env::current_dir()?.join(".taskrunner").join(name))
Ok(std::env::current_dir()?.join(".pls").join(name))
}

pub fn create_metadata_dir(name: &str) -> Result<std::path::PathBuf> {
let taskrunner_dir = metadata_path(name)?;
let config_dir = metadata_path(name)?;
debug!(
"Creating metadata dir for target <{}> at <{}>",
name,
taskrunner_dir.display()
config_dir.display()
);
std::fs::create_dir_all(&taskrunner_dir)?;
Ok(taskrunner_dir)
std::fs::create_dir_all(&config_dir)?;
Ok(config_dir)
}

fn last_run_path(target: &TargetInfo) -> Result<std::path::PathBuf> {
Expand Down
12 changes: 5 additions & 7 deletions src/targets/command/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ impl Startable for ContainerCommand {
self.target_info.name, self.command
);

let taskrunner_dir = create_metadata_dir(self.target_info.name.to_string().as_str())?;
let pid_path = taskrunner_dir.join("pid");
let log_path = taskrunner_dir.join("log");
let config_dir = create_metadata_dir(self.target_info.name.to_string().as_str())?;
let pid_path = config_dir.join("pid");
let log_path = config_dir.join("log");
let image_name =
context.resolve_substitutions(self.image.as_str(), &self.target_info.name, outputs)?;
let log_start = || {
Expand All @@ -170,11 +170,9 @@ impl Startable for ContainerCommand {
_outputs: &mut OutputsManager,
_cleanup_manager: Arc<Mutex<CleanupManager>>,
) -> Result<()> {
let taskrunner_dir = std::env::current_dir()?
.join(".taskrunner")
.join(self.target_info.name.to_string().as_str());
let config_dir = create_metadata_dir(self.target_info.name.to_string().as_str())?;

let pid_path = taskrunner_dir.join("pid");
let pid_path = config_dir.join("pid");
debug!(
"Searching for pid file for target <{}> at <{}>",
self.target_info.name,
Expand Down
Loading

0 comments on commit 45f2c29

Please sign in to comment.