Skip to content

Commit

Permalink
Merge pull request #74 from hyrodium/feature/cmd_type
Browse files Browse the repository at this point in the history
Change the type of `cmd` from `String` to `Cmd`
  • Loading branch information
terasakisatoshi authored Oct 20, 2023
2 parents 698b1ef + 4fd18d5 commit da8c4b1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
7 changes: 5 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ st
$CTRL_C
"""

replay(repl_script, stdout, julia_project=@__DIR__, use_ghostwriter=true, cmd="--color=yes")
replay(repl_script, stdout, julia_project=@__DIR__, use_ghostwriter=true, cmd=`--color=yes`)
$ julia --project=@. -e 'using Pkg; Pkg.instantiate()'
$ julia --project=@. ./examples/readme/app.jl
$ # Below is optional
Expand All @@ -68,7 +68,7 @@ $ julia --project=@. ./examples/helloworld/app.jl > output.txt
$ cat output.txt
```

Tips: you can set `replay(instructions; cmd="--color=no")` as necessary.
Tips: you can set ```replay(instructions; cmd=`--color=no`)``` as necessary.

```julia
$ julia examples/disable_color/app.jl > output.txt
Expand All @@ -89,6 +89,9 @@ See [issue #23](https://github.com/AtelierArith/Replay.jl/issues/23) to learn mo

## Breaking Changes

### `v0.5.x`
- The type of the keyword argument `cmd` has been changed from `String` to `Cmd`.

### `v0.4.x`
- The keyword argument `color` of [`replay`](@ref) is removed. Use `cmd="--color=yes"` or `cmd="--color=no"` instead.

Expand Down
2 changes: 1 addition & 1 deletion examples/disable_color/app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ instructions = [
"""greet("Hello, World!")""",
]

replay(instructions, use_ghostwriter=true, cmd="--color=no")
replay(instructions, use_ghostwriter=true, cmd=`--color=no`)
2 changes: 1 addition & 1 deletion examples/pythoncall/app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ replay(
stdout,
julia_project=@__DIR__,
use_ghostwriter=true,
cmd="--color=yes",
cmd=`--color=yes`,
)
2 changes: 1 addition & 1 deletion examples/quietmode/app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ instructions = """
println("julia -q")
"""

replay(instructions, cmd="-q")
replay(instructions, cmd=`-q`)
2 changes: 1 addition & 1 deletion examples/readme/app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ replay(
stdout,
julia_project=@__DIR__,
use_ghostwriter=true,
cmd="--color=yes",
cmd=`--color=yes`,
)
6 changes: 3 additions & 3 deletions src/Replay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function type_with_ghost(repl_script::AbstractString, mode)
clearlines(H)
end

function setup_pty(julia_project="@."::AbstractString, cmd="--color=yes")
function setup_pty(julia_project="@."::AbstractString, cmd::Cmd=`--color=yes`)
pts, ptm = open_fake_pty()
blackhole = Sys.isunix() ? "/dev/null" : "nul"
julia_exepath = joinpath(Sys.BINDIR, Base.julia_exename())
Expand All @@ -84,7 +84,7 @@ function setup_pty(julia_project="@."::AbstractString, cmd="--color=yes")
run(`$(julia_exepath) -e 'using Pkg; Pkg.instantiate()'`)
# Initialize REPL
run(
```$(julia_exepath) -i -e 'print("\x1b[?25l")' $(split(cmd))```,
```$(julia_exepath) -i -e 'print("\x1b[?25l")' $cmd```,
pts,
pts,
pts;
Expand Down Expand Up @@ -115,7 +115,7 @@ function replay(
buf::IO=stdout;
use_ghostwriter=false,
julia_project="@.",
cmd="--color=yes",
cmd::Cmd=`--color=yes`,
)
print("\x1b[?25l") # hide cursor
replproc, ptm = setup_pty(julia_project, cmd)
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mkpath(joinpath(@__DIR__, "references", version_dir))

@testset "replay: color=yes" begin
color = "yes"
buf = replay(repl_script, IOBuffer(); cmd="-q --color=yes")
buf = replay(repl_script, IOBuffer(); cmd=`-q --color=yes`)
out = buf |> take! |> String

UPDATE_REFERENCE && open(
Expand All @@ -48,7 +48,7 @@ end

@testset "replay: color=no" begin
color = "no"
buf = replay(repl_script, IOBuffer(); cmd="-q --color=no")
buf = replay(repl_script, IOBuffer(); cmd=`-q --color=no`)
out = buf |> take! |> String

UPDATE_REFERENCE && open(
Expand Down

0 comments on commit da8c4b1

Please sign in to comment.