-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(executable | ||
(public_name diffcessible) | ||
(name main) | ||
(libraries diffcessible cmdliner patch)) | ||
(libraries diffcessible cmdliner patch extunix)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
open Diffcessible | ||
open Cmdliner | ||
open ExtUnix.Specific | ||
|
||
let main file_path = | ||
let file = In_channel.open_bin file_path in | ||
let s = In_channel.input_all file in | ||
let patch = Patch.to_diffs s in | ||
let file = match file_path with | ||
| Some path -> In_channel.open_bin path | ||
| None -> | ||
let tty = ttyname Unix.stdin | ||
in In_channel.open_bin tty | ||
in let s = In_channel.input_all file | ||
in let patch = Patch.to_diffs s in | ||
Interactive_viewer.start patch | ||
|
||
let file_arg = | ||
let doc = "Path to the file containing the Git diff." in | ||
Arg.(required & pos 0 (some string) None & info [] ~docv:"FILE" ~doc) | ||
let doc = "Path to the file containing the Git diff. If not provided, reads from the terminal." in | ||
Arg.(value & pos 0 (some string) None & info [] ~docv:"FILE" ~doc) | ||
|
||
let cmd = | ||
let doc = "Render Git diffs in an accessible way." in | ||
let doc = "Render Git diffs in an accessible way. Acts as a pager if no file is provided." in | ||
let info = Cmd.info "diffcessible" ~version:"VERSION" ~doc in | ||
Cmd.v info Term.(const main $ file_arg) | ||
|
||
let () = exit (Cmd.eval cmd) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ depends: [ | |
"dune" {>= "3.11"} | ||
"cmdliner" | ||
"seq" | ||
"extunix" | ||
"notty" {>= "0.2"} | ||
"odoc" {with-doc} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
dune | ||
cmdliner | ||
seq | ||
extunix | ||
(notty | ||
(>= 0.2))) | ||
(tags | ||
|