Skip to content

Commit

Permalink
Rename ghcid-ng to ghciwatch (#131)
Browse files Browse the repository at this point in the history
People get confused about `ghcid-ng`, and it's way too many syllables.
`ghciwatch` is nice and descriptive, although if I add a `cabal build`
backend it might be a little misleading again.

Created with a handful of `sed` calls and a few file renames.
  • Loading branch information
9999years authored Oct 5, 2023
1 parent aa5a92a commit d022f8d
Show file tree
Hide file tree
Showing 37 changed files with 279 additions and 273 deletions.
4 changes: 2 additions & 2 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ failure-output = "immediate-final"
fail-fast = false

[[profile.ci.overrides]]
# `kind(test)` means integration tests in the `../ghcid-ng/tests/` directory.
# `kind(test)` means integration tests in the `../tests/` directory.
# https://nexte.st/book/filter-expressions.html#basic-predicates
filter = 'package(ghcid-ng) and kind(test)'
filter = 'package(ghciwatch) and kind(test)'
platform = 'cfg(linux)'
test-group = 'serial-integration'
30 changes: 15 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ jobs:
- name: Create macOS universal executable
if: runner.os == 'macOS'
run: |
lipo -create -output target/release/ghcid-ng-macos \
target/x86_64-apple-darwin/release/ghcid-ng \
target/aarch64-apple-darwin/release/ghcid-ng
lipo -create -output target/release/ghciwatch-macos \
target/x86_64-apple-darwin/release/ghciwatch \
target/aarch64-apple-darwin/release/ghciwatch
- uses: cachix/install-nix-action@v22
if: runner.os == 'Linux'
Expand All @@ -113,30 +113,30 @@ jobs:
if: runner.os == 'Linux'
run: |
mkdir -p target/
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghcid-ng)
cp "$RESULT/bin/ghcid-ng" target/ghcid-ng-x86_64-linux
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghciwatch)
cp "$RESULT/bin/ghciwatch" target/ghciwatch-x86_64-linux
- name: Build (Linux, aarch64)
if: runner.os == 'Linux'
run: |
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghcid-ng-aarch64-linux)
cp "$RESULT/bin/ghcid-ng" target/ghcid-ng-aarch64-linux
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghciwatch-aarch64-linux)
cp "$RESULT/bin/ghciwatch" target/ghciwatch-aarch64-linux
- name: Upload macOS executable
uses: actions/upload-artifact@v3
if: runner.os == 'macOS'
with:
name: macos
path: target/release/ghcid-ng-macos
path: target/release/ghciwatch-macos

- name: Upload Linux executables
uses: actions/upload-artifact@v3
if: runner.os == 'Linux'
with:
name: linux
path: |
target/ghcid-ng-x86_64-linux
target/ghcid-ng-aarch64-linux
target/ghciwatch-x86_64-linux
target/ghciwatch-aarch64-linux
- name: Publish to crates.io
if: runner.os == 'Linux'
Expand Down Expand Up @@ -170,9 +170,9 @@ jobs:
# - uses: actions/upload-artifact@v3
# with:
# name: linux
# path: target/release/ghcid-ng-aarch64-linux
# path: target/release/ghciwatch-aarch64-linux
#
# will be downloaded to `linux/ghcid-ng-aarch64-linux`.
# will be downloaded to `linux/ghciwatch-aarch64-linux`.
uses: actions/download-artifact@v3

- name: Create release
Expand All @@ -186,9 +186,9 @@ jobs:
generate_release_notes: true
tag_name: v${{ needs.version.outputs.version }}
files: |
macos/ghcid-ng-macos
linux/ghcid-ng-x86_64-linux
linux/ghcid-ng-aarch64-linux
macos/ghciwatch-macos
linux/ghciwatch-x86_64-linux
linux/ghciwatch-aarch64-linux
- name: Comment on PR with link to the release
uses: peter-evans/create-or-update-comment@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Are you here because I left Mercury and now my personal access token is
# invalid for workflows, breaking CI? You'll want to go to
# https://github.com/MercuryTechnologies/ghcid-ng/settings/secrets/actions
# https://github.com/MercuryTechnologies/ghciwatch/settings/secrets/actions
# and update the `REPO_GITHUB_TOKEN` secret to a new, valid token.

on:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ publish = false # Don't do `cargo publish`.

# Define the root package: https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package
[package]
name = "ghcid-ng"
name = "ghciwatch"
version = "0.3.7"
edition = "2021"
authors = [
"Rebecca Turner <[email protected]>"
]
description = "ghci-based file watcher and recompiler for Haskell projects"
readme = "README.md"
homepage = "https://github.com/MercuryTechnologies/ghcid-ng"
repository = "https://github.com/MercuryTechnologies/ghcid-ng"
homepage = "https://github.com/MercuryTechnologies/ghciwatch"
repository = "https://github.com/MercuryTechnologies/ghciwatch"
license = "MIT"
keywords = ["haskell", "ghci", "watchexec"]
categories = ["command-line-utilities", "development-tools"]
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ghcid-ng
# ghciwatch

The next generation of [`ghcid`][ghcid], a [`ghci`][ghci]-based file watcher
and recompiler. `ghcid-ng` watches your modules for changes and reloads them in
and recompiler. `ghciwatch` watches your modules for changes and reloads them in
a `ghci` session, displaying any errors.

[ghcid]: https://github.com/ndmitchell/ghcid
Expand All @@ -10,7 +10,7 @@ a `ghci` session, displaying any errors.

## Why a reimplementation?

When we started working on `ghcid-ng`, `ghcid` suffered from some significant
When we started working on `ghciwatch`, `ghcid` suffered from some significant
limitations. In particular, `ghcid` couldn't deal with moved or deleted
modules, and wouldn't detect new directories because it [can't easily update
the set of files being watched at runtime.][ghcid-wait] We've also seen memory
Expand All @@ -26,7 +26,7 @@ forward than making wide-spanning changes to an unfamiliar codebase.
Rust makes it easy to ship static binaries. Rust also shares many features with
Haskell: a [Hindley-Milner type system][hm] with inference, pattern matching,
and immutability by default. Rust can also [interoperate with
Haskell][hs-bindgen], so in the future we'll be able to ship `ghcid-ng` as a
Haskell][hs-bindgen], so in the future we'll be able to ship `ghciwatch` as a
Hackage package natively. Finally, Rust is home to the excellent cross-platform
and battle-tested [`watchexec`][watchexec] library, used to implement the
`watchexec` binary and `cargo-watch`, which solves a lot of the thorny problems
Expand All @@ -42,7 +42,7 @@ of watching files for us.
Recompiling a project when files change is a fairly common development task, so
there's a bunch of tools with this same rough goal. In particular,
[`watchexec`][watchexec] is a nice off-the-shelf solution. Why not just run
`watchexec -e hs cabal build`? In truth, `ghcid-ng` doesn't just recompile the
`watchexec -e hs cabal build`? In truth, `ghciwatch` doesn't just recompile the
project when it detects changes. It instead manages an interactive `ghci`
session, instructing it to reload modules when relevant. This involves a fairly
complex dance of communicating to `ghci` over stdin and parsing its stdout, so
Expand Down
24 changes: 12 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@

pkgs = makePkgs {};

make-ghcid-ng = pkgs:
pkgs.callPackage ./nix/ghcid-ng.nix {} {
make-ghciwatch = pkgs:
pkgs.callPackage ./nix/ghciwatch.nix {} {
# GHC versions to include in the environment for integration tests.
# Keep this in sync with `./test-harness/src/ghc_version.rs`.
ghcVersions = [
Expand All @@ -86,15 +86,15 @@
];
};

ghcid-ng = make-ghcid-ng pkgs;
ghciwatch = make-ghciwatch pkgs;
in {
inherit (ghcid-ng) checks;
inherit (ghciwatch) checks;

packages =
{
inherit ghcid-ng;
default = ghcid-ng;
ghcid-ng-tests = ghcid-ng.checks.ghcid-ng-tests;
inherit ghciwatch;
default = ghciwatch;
ghciwatch-tests = ghciwatch.checks.ghciwatch-tests;

get-crate-version = pkgs.callPackage ./nix/get-crate-version.nix {};
make-release-commit = pkgs.callPackage ./nix/make-release-commit.nix {};
Expand All @@ -109,17 +109,17 @@
};
}
// (pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
# ghcid-ng cross-compiled to aarch64-linux.
ghcid-ng-aarch64-linux = let
# ghciwatch cross-compiled to aarch64-linux.
ghciwatch-aarch64-linux = let
crossPkgs = makePkgs {crossSystem = "aarch64-linux";};
in
(make-ghcid-ng crossPkgs).overrideAttrs (old: {
(make-ghciwatch crossPkgs).overrideAttrs (old: {
CARGO_BUILD_TARGET = "aarch64-unknown-linux-musl";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER = "${crossPkgs.stdenv.cc.targetPrefix}cc";
});
});

apps.default = flake-utils.lib.mkApp {drv = ghcid-ng;};
apps.default = flake-utils.lib.mkApp {drv = ghciwatch;};

devShells.default = pkgs.craneLib.devShell {
checks = self.checks.${localSystem};
Expand All @@ -128,7 +128,7 @@
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;

# Provide GHC versions to use to the integration test suite.
inherit (ghcid-ng) GHC_VERSIONS;
inherit (ghciwatch) GHC_VERSIONS;

# Extra development tools (cargo and rustc are included by default).
packages = [
Expand Down
4 changes: 2 additions & 2 deletions nix/get-crate-version.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ writeShellApplication {
];

text = ''
# Gets the version of `ghcid-ng` in `Cargo.toml` using
# Gets the version of `ghciwatch` in `Cargo.toml` using
# `cargo metadata` and `jq`.
VERSION=$(cargo metadata --format-version 1 \
| jq -r '.packages[] | select(.name == "ghcid-ng") | .version')
| jq -r '.packages[] | select(.name == "ghciwatch") | .version')
echo "Version in \`Cargo.toml\` is $VERSION" 1>&2
Expand Down
14 changes: 7 additions & 7 deletions nix/ghcid-ng.nix → nix/ghciwatch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
};

checks = {
ghcid-ng-tests = craneLib.cargoNextest (commonArgs
ghciwatch-tests = craneLib.cargoNextest (commonArgs
// {
buildInputs = (commonArgs.buildInputs or []) ++ ghcBuildInputs;
NEXTEST_PROFILE = "ci";
Expand All @@ -94,18 +94,18 @@
# Provide GHC versions to use to the integration test suite.
inherit GHC_VERSIONS;
});
ghcid-ng-clippy = craneLib.cargoClippy (commonArgs
ghciwatch-clippy = craneLib.cargoClippy (commonArgs
// {
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
inherit GHC_VERSIONS;
});
ghcid-ng-doc = craneLib.cargoDoc (commonArgs
ghciwatch-doc = craneLib.cargoDoc (commonArgs
// {
cargoDocExtraArgs = "--document-private-items";
RUSTDOCFLAGS = "-D warnings";
});
ghcid-ng-fmt = craneLib.cargoFmt commonArgs;
ghcid-ng-audit = craneLib.cargoAudit (commonArgs
ghciwatch-fmt = craneLib.cargoFmt commonArgs;
ghciwatch-audit = craneLib.cargoAudit (commonArgs
// {
inherit advisory-db;
});
Expand Down Expand Up @@ -140,11 +140,11 @@ in
craneLib.buildPackage (commonArgs
// {
# Don't run tests; we'll do that in a separate derivation.
# This will allow people to install and depend on `ghcid-ng`
# This will allow people to install and depend on `ghciwatch`
# without downloading a half dozen different versions of GHC.
doCheck = false;

# Only build `ghcid-ng`, not the test macros.
# Only build `ghciwatch`, not the test macros.
cargoBuildCommand = "cargoWithProfile build";

passthru = {
Expand Down
10 changes: 5 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::normal_path::NormalPath;
pub struct Opts {
/// A shell command which starts a `ghci` REPL, e.g. `ghci` or `cabal v2-repl` or similar.
///
/// This is used to launch the underlying `ghci` session that `ghcid-ng` controls.
/// This is used to launch the underlying `ghci` session that `ghciwatch` controls.
///
/// May contain quoted arguments which will be parsed in a `sh`-like manner.
#[arg(long, value_name = "SHELL_COMMAND")]
Expand Down Expand Up @@ -111,8 +111,8 @@ pub struct LoggingOpts {
///
/// See: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html
///
/// A nice value is "ghcid_ng=debug".
#[arg(long, default_value = "ghcid_ng=info")]
/// A nice value is "ghciwatch=debug".
#[arg(long, default_value = "ghciwatch=info")]
pub tracing_filter: String,

/// How to display backtraces in error messages.
Expand All @@ -137,7 +137,7 @@ pub struct LoggingOpts {

/// Lifecycle hooks.
///
/// These are commands (mostly `ghci` commands) to run at various points in the `ghcid-ng`
/// These are commands (mostly `ghci` commands) to run at various points in the `ghciwatch`
/// lifecycle.
#[derive(Debug, Clone, clap::Args)]
#[clap(next_help_heading = "Lifecycle hooks")]
Expand Down Expand Up @@ -184,7 +184,7 @@ pub struct HookOpts {
/// `ghci` commands to run after restarting `ghci`.
/// Can be given multiple times.
///
/// `ghci` cannot reload after files are deleted due to a bug, so `ghcid-ng` has to restart the
/// `ghci` cannot reload after files are deleted due to a bug, so `ghciwatch` has to restart the
/// underlying `ghci` session when this happens. Note that the `--before-restart-ghci` and
/// `--after-restart-ghci` commands will therefore run in different `ghci` sessions without
/// shared context.
Expand Down
2 changes: 1 addition & 1 deletion src/event_filter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Parsing [`watchexec::event::Event`]s into changes `ghcid-ng` can respond to.
//! Parsing [`watchexec::event::Event`]s into changes `ghciwatch` can respond to.
use std::collections::HashMap;

Expand Down
6 changes: 3 additions & 3 deletions src/ghci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ use self::parse::parse_eval_commands;

/// The `ghci` prompt we use. Should be unique enough, but maybe we can make it better with Unicode
/// private-use-area codepoints or something in the future.
pub const PROMPT: &str = "###~GHCID-NG-PROMPT~###";
pub const PROMPT: &str = "###~GHCIWATCH-PROMPT~###";

/// The name we import `System.IO` as in `ghci`. This is used to run a few `putStrLn` commands and
/// similar without messing with the user's namespace. If you have a module in your project named
/// `GHCID_NG_IO_INTERNAL__` that's on you.
pub const IO_MODULE_NAME: &str = "GHCID_NG_IO_INTERNAL__";
/// `GHCIWATCH_IO_INTERNAL__` that's on you.
pub const IO_MODULE_NAME: &str = "GHCIWATCH_IO_INTERNAL__";

/// Options for constructing a [`Ghci`]. This is like a lower-effort builder interface, mostly provided
/// because Rust tragically lacks named arguments.
Expand Down
2 changes: 1 addition & 1 deletion src/ghci/parse/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::ghci::GhciCommand;
use super::lines::rest_of_line;
use super::lines::until_newline;

/// A (Haskell) command for `ghcid-ng` to evaluate in `ghci`.
/// A (Haskell) command for `ghciwatch` to evaluate in `ghci`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EvalCommand {
/// The Haskell code or `ghci` command to evaluate.
Expand Down
Loading

0 comments on commit d022f8d

Please sign in to comment.