Skip to content

Commit

Permalink
Merge pull request #11 from PeteXC/upgrade-docs
Browse files Browse the repository at this point in the history
docs: updated documentation for task syntax
  • Loading branch information
joerdav authored May 25, 2022
2 parents 3c05f2a + 42e3243 commit f3436aa
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 15 deletions.
2 changes: 1 addition & 1 deletion doc/content/introduction.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
linkTitle: Introduction
title: xc - Simple, Convenient, Markdown based task runner.
title: xc - Simple, Convenient, Markdown based task runner.
type: homepage
date: 2022-03-19:15:00+00:00
---
Expand Down
18 changes: 17 additions & 1 deletion doc/content/task-syntax/command.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@ linkTitle: "Task Command"
menu: { main: { parent: 'task-syntax', weight: 10 } }
---

TODO: Document command syntax
## How to define a command to run a task

The command of a task is what will be executed through the command line when the task is run.

To define a command you must add a code block under a particular task.

````markdown
## Tasks
### Task1
```
echo "Hello 世界!"
echo "Hello العالمية!"
echo "Hello ертөнц!"
```
````

Everything inside the code block will be run on the command line as if it is a shell script.
8 changes: 0 additions & 8 deletions doc/content/task-syntax/dependancies.md

This file was deleted.

72 changes: 72 additions & 0 deletions doc/content/task-syntax/dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: "Dependencies"
description:
linkTitle: "Dependencies"
menu: { main: { parent: 'task-syntax', weight: 10 } }
---

## How to create a dependency between two tasks

You can run another before the task you're trying to run as a dependency.

For example, you want to run a task to deploy your code, but you want to run all the unit tests and linters before that happens.

Before the command section of the task, you may define comma seperated dependencies with `requires:` or `req:` followed by the name of the tasks that are dependencies.

````markdown
## Tasks

### Test
```
sh test.sh
```

### Lint
```
sh lint.sh
```

### Deploy
requires: Test, Lint
```
sh deploy.sh
```
````

## Chaining tasks with dependencies

You can chain tasks through the use of dependencies.

````markdown
## Tasks

### Task1
```
echo "TASK 1"
```

### Task2
requires: Task1
```
echo "TASK 2"
```

### Task3
requires: Task2
```
echo "TASK 3"
```
````

Running `xc Task3` will yield:

```
echo "TASK 1"
TASK 1
echo "TASK 2"
TASK 2
echo "TASK 3"
TASK 3
```

Running in the order of `Task1` -> `Task2` -> `Task`
15 changes: 14 additions & 1 deletion doc/content/task-syntax/directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@ linkTitle: "Directory"
menu: { main: { parent: 'task-syntax', weight: 10 } }
---

TODO: Document Directory keyword
## How to use a custom working directory

You can define the working directory of the task for the command to run in.

Do this by adding a `dir:` or `directory:` between the H3 of the task name and the command.

````markdown
## Tasks
### Build
directory: ./src
```
sh build.sh
```
````
41 changes: 40 additions & 1 deletion doc/content/task-syntax/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,44 @@ description:
linkTitle: "Environment Variables"
menu: { main: { parent: 'task-syntax', weight: 10 } }
---
## How to use environment variables

TODO: Document Env
You can define environment variables that will be used during the execution of your task.

Do this by adding an `env:` or `environment:` between the H3 of the task name and the command

````markdown
## Tasks
### Task1
Env: ENVIRONMENT=PRODUCTION
```
echo $ENVIRONMENT
```
````

## Multiple environment variables

You can define multiple environment variables.

````markdown
## Tasks
### Task1
Env: ENVIRONMENT=PRODUCTION
Env: VERSION=1.2
```
echo $ENVIRONMENT
echo $VERSION
```
````

or

````markdown
## Tasks
### Task1
Env: ENVIRONMENT=PRODUCTION, VERSION=1.2
```
echo $ENVIRONMENT
echo $VERSION
```
````
11 changes: 10 additions & 1 deletion doc/content/task-syntax/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
---
title: "Task Syntax"
weight: 1
description: Task Syntax
description:
linkTitle: "Task Syntax"
---

## The anatomy of an `xc` task.

### Structure

- Tasks Section
- Task Name
- Dependencies
- Directory
- Environment Variables
- Command

### Example

````md
Expand Down
28 changes: 27 additions & 1 deletion doc/content/task-syntax/task-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,30 @@ linkTitle: "Name"
menu: { main: { parent: 'task-syntax', weight: 2 } }
---

TODO: Document names
## How to define a task

Under the `## Tasks` heading, you may define as many tasks as you'd like. Each task is defined with a name by adding a H3 heading like `### TaskName`

```markdown
## Tasks

### Task1

### Task2

### Task3
```

## Constraints

You cannot use spaces in the task name.

But you may use `-` or `_`

```markdown
## Tasks

### Task_1

### Task-2
```
36 changes: 35 additions & 1 deletion doc/content/task-syntax/tasks-section.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,38 @@ linkTitle: "Tasks Section"
menu: { main: { parent: 'task-syntax', weight: 1 } }
---

TODO: Tasks section
## Tasks Section

An xc compatible markdown file needs to define a heading of any level called `Tasks`.

The tasks within a `Tasks` section will need to be one heading level lower than `Tasks`.

```markdown
## Tasks

### Task1

### Task2

## Next H2 Heading
```

Between `## Tasks` and `## Next H2 Heading` you can define your tasks.

or

```markdown
# Tasks

## Task1

## Task2

# Next H1 Heading
```

Please note that the word `tasks` is not case sensitive.

## Constraints

You cannot define two `Tasks` sections. If you do, the one that appears first in the markdown file will be used

0 comments on commit f3436aa

Please sign in to comment.