Skip to content

Add version/date API #26

@codesections

Description

@codesections

I am including version and date in the same issue because I've checked several man(1) pages and noticed that the formatting of the two is related: specifically, the version will be displayed in the bottom center of the page if the man page doesn't have a date. If the man page has a date, the date is displayed in the bottom center of the page and the version is moved to the left.

I also note that we can use the env!("CARGO_PACKAGE_VERSION") macro to read the version from the Cargo.toml file and that version is a required field. Based on the above, I propose the following API:

Default (nothing specified; assume the Cargo.toml version is 0.2.0)

Manual::new("basic");

prints at the bottom:

                                       0.2.0                                    BASIC(1)

Date

Manual::new("basic")
  .date("August 2017");
0.2.0                                August 2017                              BASIC(1)

Date & Custom version

Manual::new("basic")
  .date("January 1, 2019")
  .version("0.1.0");
0.1.0                                January 1, 2017                          BASIC(1)

Custom date & no version

Manual::new("basic")
  .date("2015-05-23")
  .version("");
                                       2015-05-23                             BASIC(1)

Note: the API I suggest takes a str for the date and leaves the exact formatting to the user. It could, of course, take a date string or something (perhaps using Chrono) and format the date for the user. But, based on looking at a few man pages, there doesn't seem to be consensus on how to format dates and it seems better to leave that to the users.

Any thoughts on this API before I work on a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions