Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 48 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,63 @@
on: pull_request

name: Continuous integration
name: Continuous Integration

env:
RUSTFLAGS: -D warnings

jobs:
ci:
runs-on: ${{ matrix.os }}
name: ${{ matrix.target.name }} [${{ matrix.rust_version }}]
runs-on: ${{ matrix.target.os }}
strategy:
fail-fast: false
matrix:
rust:
- stable
os: [ubuntu-latest, windows-latest]
rust_version: ["stable", "1.62.1"]
target:
- name: Linux
os: ubuntu-latest
extra_flags: --all-features
run_tests: true

- name: Linux (no-std)
os: ubuntu-latest
extra_flags: --no-default-features
run_tests: true

- name: Windows
os: windows-latest
extra_flags: --all-features
run_tests: true

- name: Windows (no-std)
os: windows-latest
extra_flags: --no-default-features
run_tests: true

- name: Bare Metal (no-std)
os: ubuntu-latest
extra_flags: --no-default-features
run_tests: false
env:
TARGET: thumbv7em-none-eabihf


steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
targets: ${{ matrix.target.env.TARGET || '' }}
toolchain: ${{ matrix.rust_version }}
components: clippy, rustfmt

- run: cargo fmt --check --all
- run: cargo clippy -- -D warnings
- run: cargo build --all-features
- run: cargo test
- run: cargo test --all-features
- run: cargo run --example 256_colors
- run: cargo run --example hyperlink
- run: cargo run --example title
- run: cargo clippy ${{ matrix.target.extra_flags }}
- run: cargo build ${{ matrix.target.extra_flags }}

- if: matrix.target.run_tests
run: |
cargo test ${{ matrix.target.extra_flags }}
cargo run ${{ matrix.target.extra_flags }} --example 256_colors
cargo run ${{ matrix.target.extra_flags }} --example hyperlink
cargo run ${{ matrix.target.extra_flags }} --example title
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
target
Cargo.lock

# JetBrains' IDE items
.idea/*
Expand Down
195 changes: 195 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ repository = "https://github.com/nushell/nu-ansi-term"
doctest = true

[features]
default = ["std"]
std = []
derive_serde_style = ["serde"]
gnu_legacy = []

Expand Down
2 changes: 1 addition & 1 deletion examples/256_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nu_ansi_term::Color;
// - 232 to 255 are shades of grey.

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

// First two lines
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use nu_ansi_term::{Color::*, Style};
// This example prints out the 16 basic colors.

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

let normal = Style::default();
Expand Down
2 changes: 1 addition & 1 deletion examples/gradient_colors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use nu_ansi_term::{build_all_gradient_text, Color, Gradient, Rgb, TargetGround};

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

let text = "lorem ipsum quia dolor sit amet, consectetur, adipisci velit";
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod may_sleep;
use may_sleep::{parse_cmd_args, sleep};

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

let sleep_ms = parse_cmd_args();
Expand Down
2 changes: 1 addition & 1 deletion examples/rgb_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const WIDTH: i32 = 80;
const HEIGHT: i32 = 24;

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

for row in 0..HEIGHT {
Expand Down
2 changes: 1 addition & 1 deletion examples/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod may_sleep;
use may_sleep::{parse_cmd_args, sleep};

fn main() {
#[cfg(windows)]
#[cfg(all(windows, feature = "std"))]
nu_ansi_term::enable_ansi_support().unwrap();

let sleep_ms = parse_cmd_args();
Expand Down
6 changes: 4 additions & 2 deletions src/ansi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(missing_docs)]
use crate::style::{Color, Style};
use crate::write::AnyWrite;
use std::fmt;
use core::fmt;

impl Style {
/// Write any bytes that go *before* a piece of text to the given writer.
Expand Down Expand Up @@ -400,6 +400,7 @@ impl fmt::Display for Suffix {
}

#[cfg(test)]
#[allow(unused)]
macro_rules! test {
($name: ident: $style: expr; $input: expr => $result: expr) => {
#[test]
Expand All @@ -414,8 +415,9 @@ macro_rules! test {
}

#[cfg(test)]
#[cfg(not(feature = "gnu_legacy"))]
#[cfg(all(not(feature = "gnu_legacy"), feature = "std"))]
mod test {

use crate::style::Color::*;
use crate::style::Style;
use crate::Color;
Expand Down
2 changes: 1 addition & 1 deletion src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::style::Style;
use std::fmt;
use core::fmt;

/// Styles have a special `Debug` implementation that only shows the fields that
/// are set. Fields that haven’t been touched aren’t included in the output.
Expand Down
Loading
Loading