Skip to content

Commit

Permalink
✅ restore testing, add CI workflow and README.md (#16)
Browse files Browse the repository at this point in the history
* ✅ restore testing, add CI workflow and `README.md`

* ⏪ move `example.nu` back into the benches\ folder

* ⏪ return benchmarking with `criterion`
  • Loading branch information
AucaCoyan committed Jun 6, 2023
1 parent 0b42976 commit 2435913
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 454 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/clippy_check.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow run when something is pushed on main and it does
# normal checks like in the normal PRs

# Jobs on pull request
name: CI on main
on:
workflow_dispatch:
push:
branches:
- main

jobs:
format:
name: format rust files
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: format files
run: cargo fmt --all --check

lint:
name: lint all rust files
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: Clippy
run: cargo clippy --no-deps

test:
name: test rust files
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: run tests
run: cargo test --workspace
43 changes: 43 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Jobs on pull request
name: Pull request
on: pull_request

jobs:
format:
name: format rust files
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: format files
run: cargo fmt --all --check

lint:
name: lint all rust files
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: Clippy
run: cargo clippy --no-deps

test:
name: test rust files
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
- name: run tests
run: cargo test --workspace
75 changes: 8 additions & 67 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ nu-parser = "0.80.0"
nu-protocol = "0.80.0"

[dev-dependencies]
criterion = "0.4"
criterion = "0.5.1"

[features]
default = ["bin"]
Expand All @@ -38,5 +38,5 @@ path = "src/main.rs"
required-features = ["bin"]

[[bench]]
name = "bench"
name = "file-format-bench"
harness = false
82 changes: 74 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
# Nushell script formatter
<div align="center">

## some example formatting
[`g.nu`](examples/g.nu) should get formatted into [`gradient.nu`](examples/gradient.nu)
# `nufmt`: the nushell formatter

> **Warning**
> these scripts are very much deprecated, see the `0.31.1` version of `nushell`!!
> we're now in `0.74` on latest `main` :muscle:
[![MIT licensed][mit-badge]][mit-url]
[![Discord chat][discord-badge]][discord-url]
[![CI on main][ci-badge]][ci-url]
[![nushell version][nushell-badge]][nushell-url]

> **Note**
> true ideal examples *COMING SOON* :wink:
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg?color=brightgreen
[mit-url]: LICENSE
[discord-badge]: https://img.shields.io/discord/678763474494423051?logo=discord&label=discord&color=brightgreen
[discord-url]: https://discord.gg/NtAbbGn
[ci-badge]: https://github.com/AucaCoyan/nufmt/actions/workflows/main.yml/badge.svg
[ci-url]: https://github.com/AucaCoyan/nufmt/actions/workflows/main.yml
[nushell-badge]: https://img.shields.io/badge/nushell-v0.80.0-green
[nushell-url]: https://crates.io/crates/nu

</div>

## Table of contents

- [Status](#status)
- [Usage](#usage)
- [Files](#files)
- [Options](#options)
- [Contributing](#contributing)

## Status

This project is still very much in beta. Expect bugs, unconsistent behaviour. Do not use in productive nushell scripts!

Some of the outputs deletes comments, break the functionality of the script or doesn't format at all.

To use the formatter, test it first and use it with caution!.

## Usage

If you still want to use it, or test it to contribute, this is the `--help`.

```text
nufmt [OPTIONS] [FILES] ...
```

### Files

`Files` are a list of files. It cannot be used combined with `--stdin`.
You can format many files with one command!. For example:

```text
nufmt my-file1.nu my-file2.nu my-file3.nu
```

### Options

- `-s` or `--stdin` formats from `stdin`, returns to `stdout` as a String. It cannot be used combined with `files`.
- `-c` or `--config` pass the config file path.
Sample:

```text
nufmt <files> --config my-config.json
```

or

```text
nufmt --stdin <string> --config my-stdin-config.json
```

- `-h` or `--help` show help and exit
- `-v` or `--version` prints the version and exit

## Contributing

Submit an issue, or come and say hi in the [Discord](https://discord.gg/NtAbbGn)!

You can mention @AucaCoyan who is active on this repo.
17 changes: 0 additions & 17 deletions benches/bench.rs

This file was deleted.

File renamed without changes.

0 comments on commit 2435913

Please sign in to comment.