Skip to content

Commit

Permalink
Prepare for 0.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
gridbugs committed Jan 31, 2025
1 parent c874293 commit 9a97582
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 30 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Changelog

## Unreleased
## 0.4.0

### Added

- Allow help messages colours to be configured (#7)
- Proof of concept of manpage generation (#11)
- Proof of concept of manpage generation (disabled in release as it's very incompletel) (#11)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion dune-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

(env
(dev
(flags :standard -warn-error -26-27-32-33-34-37-39-23)))
(flags :standard -warn-error -26-27-32-33-34-37-39-23-38)))
15 changes: 8 additions & 7 deletions src/climate/climate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let name_of_string_exn string =
(* TODO: Explore using a variant rather than raising exceptions for non-returning arg
parsers such as `--help` and `--manpage` *)
exception Usage
exception Manpage
(*exception Manpage*)

module Subcommand = struct
type t =
Expand Down Expand Up @@ -666,7 +666,7 @@ module Arg_parser = struct
~repeated:false
;;

let manpage_spec =
let _manpage_spec =
Spec.create_flag Built_in.manpage_names ~desc:None ~hidden:true ~repeated:false
;;

Expand All @@ -686,7 +686,8 @@ module Arg_parser = struct
;;

let add_help_and_manpage { arg_spec; arg_compute } ~desc ~child_subcommands ~prose =
let arg_spec = arg_spec |> Spec.merge help_spec |> Spec.merge manpage_spec in
let _ = prose in
let arg_spec = arg_spec |> Spec.merge help_spec (*|> Spec.merge manpage_spec *) in
{ arg_spec
; arg_compute =
(fun context help_info ->
Expand All @@ -700,8 +701,8 @@ module Arg_parser = struct
context.command_line
~desc
~child_subcommands;
raise Usage)
else if Raw_arg_table.get_flag_count_names
raise Usage
(*else if Raw_arg_table.get_flag_count_names
context.raw_arg_table
Built_in.manpage_names
> 0
Expand All @@ -710,7 +711,7 @@ module Arg_parser = struct
let help = help arg_spec context.command_line ~desc ~child_subcommands in
let manpage = { Manpage.prose; help; version = help_info.version } in
print_endline (Manpage.to_troff_string manpage);
raise Manpage)
raise Manpage) *))
else arg_compute context help_info)
}
;;
Expand Down Expand Up @@ -1156,7 +1157,7 @@ module Command = struct
| Parse_error.E e ->
Printf.eprintf "%s" (Parse_error.to_string e);
exit Parse_error.exit_code
| Usage | Manpage -> exit 0
| Usage (*| Manpage*) -> exit 0
;;

let run_singleton
Expand Down
4 changes: 0 additions & 4 deletions tests/completion_tests/basic/test.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--baz
--foo
--help
--manpage
-h

$ x "basic --" \
Expand All @@ -16,7 +15,6 @@
--baz
--foo
--help
--manpage

$ x "basic --b" \
> " ^"
Expand All @@ -38,7 +36,6 @@
--baz
--foo
--help
--manpage
-h

$ x "basic --foo --bar " \
Expand All @@ -47,7 +44,6 @@
--baz
--foo
--help
--manpage
-h

$ x "basic --foo --bar" \
Expand Down
5 changes: 0 additions & 5 deletions tests/completion_tests/fake_git/test.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ Make a fake .git directory with some branches.
$ x "fake-git log -" \
> " ^"
--help
--manpage
--pretty
-h
-p

$ x "fake-git log --" \
> " ^"
--help
--manpage
--pretty

$ x "fake-git log --pretty " \
Expand All @@ -81,7 +79,6 @@ Make a fake .git directory with some branches.
$ x "fake-git log --pretty full foo " \
> " ^"
--help
--manpage
--pretty
-h
-p
Expand All @@ -97,13 +94,11 @@ Test that positional arguments and subcommands are both listed.
$ x "fake-git bisect -" \
> " ^"
--help
--manpage
-h

$ x "fake-git bisect start " \
> " ^"
--help
--manpage
-h

Test the behaviour of arguments with no hints.
Expand Down
5 changes: 0 additions & 5 deletions tests/completion_tests/fake_git/test_minified.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ Make a fake .git directory with some branches.
$ x "fake-git log -" \
> " ^"
--help
--manpage
--pretty
-h
-p

$ x "fake-git log --" \
> " ^"
--help
--manpage
--pretty

$ x "fake-git log --pretty " \
Expand All @@ -89,7 +87,6 @@ Make a fake .git directory with some branches.
$ x "fake-git log --pretty full foo " \
> " ^"
--help
--manpage
--pretty
-h
-p
Expand All @@ -105,13 +102,11 @@ Test that positional arguments and subcommands are both listed.
$ x "fake-git bisect -" \
> " ^"
--help
--manpage
-h

$ x "fake-git bisect start " \
> " ^"
--help
--manpage
-h

Test the behaviour of arguments with no hints.
Expand Down
12 changes: 6 additions & 6 deletions tests/usage_tests/help_messages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ let%expect_test "arguments" =
<ARG2> The second argument

Options:
-f, --foo <FILE> description of foo
--bar <ABC> description of bar
-c <INT>
-h, --help Show this help message.
-c <INT>
--bar <ABC> description of bar
-f, --foo <FILE> description of foo
|}]
;;

Expand Down Expand Up @@ -200,8 +200,8 @@ let%expect_test "arguments and subcommands" =
Usage: foo.exe log [OPTIONS]

Options:
-p, --pretty <VALUE>
-h, --help Show this help message.
-p, --pretty <VALUE>
|}];
run command [ "commit"; "--help" ];
[%expect
Expand All @@ -211,8 +211,8 @@ let%expect_test "arguments and subcommands" =
Usage: foo.exe commit [OPTIONS]

Options:
-a, --amend
-m, --message <STRING>
-h, --help Show this help message.
-m, --message <STRING>
-a, --amend
|}]
;;

0 comments on commit 9a97582

Please sign in to comment.