dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
678 stars 75 forks source link

Man Page #136

Open satiowadahc opened 3 years ago

satiowadahc commented 3 years ago

Being lazy and don't want to clone the repo, feel free to add it in. Save this excerpt as timetrace.1 gzip timetrace.1 sudo cp timetrace.1.gz /usr/share/man/man1/timetrace.1.gz

.\" Manpage for timetrace.
.\" See https://github.com/dominikbraun/timetrace to correct errors or typos.
.TH man 1 2021-06-22 0.10.0 "Time Trace man page"
.SH NAME
timetrace - Command Line Based Time Tracker
.SH SYNOPSIS
.B timetrace [status | list | start | stop | create | delete] [project | record] <module@><project>
.SH DESCRIPTION
.B timetrace
is a simple CLI for tracking your working time.
.SH OPTIONS
.TP
.B status
Display the tracking status
.TP
.B list
List projects or records.
.TP
.B start
Start tracking time to a project or module, -b to make it billable
.TP
.B stop
Stop tracking current project
.TP
.B create
Create project or module
.TP
.B delete
Delete project or module
.SH Examples
.TP
timetrace status
.TP
timetrace create project grind-beans@make-coffee
.TP
timetrace start make-coffee
.TP
timetrace stop
.TP
timetrace list projects
.TP
timetrace list records
.SH BUGS
- See GitHub Issues
.SH AUTHOR
@dominikbraun
satiowadahc commented 3 years ago

output:

man(1)                                                                                                                                          Time Trace man page                                                                                                                                          man(1)

NAME
       timetrace - Command Line Based Time Tracker

SYNOPSIS
       timetrace [status | list | start | stop | create | delete] [project | record] <module@><project>

DESCRIPTION
       timetrace is a simple CLI for tracking your working time.

OPTIONS
       status Display the tracking status

       list   List projects or records.

       start  Start tracking time to a project or module, -b to make it billable

       stop   Stop tracking current project

       create Create project or module

       delete Delete project or module

Examples
       timetrace status

       timetrace create project grind-beans@make-coffee

       timetrace start make-coffee

       timetrace stop

       timetrace list projects

       timetrace list records

BUGS
       - See GitHub Issues

AUTHOR
       @dominikbraun

0.10.0    
Kevin-Mok commented 3 years ago

I wonder if this can be somewhat auto-generated with Cobra like in #84 and worked into the CI? @obnoxiousnerd

satiowadahc commented 3 years ago

IMHO its nice to have something quick and at a glance, add it first, automate later.

In regards to automation Most projects I work on have the options, version, and date automated and the rest manually entered.

Kevin-Mok commented 3 years ago

IMHO its nice to have something quick and at a glance, add it first, automate later.

Makes sense.

In regards to automation Most projects I work on have the options, version, and date automated and the rest manually entered.

I'm thinking something like a man page template in Go where options, version, and date can be inserted. What do you think of that, @obnoxiousnerd?

dominikbraun commented 3 years ago

@aligator PTAL

retronav commented 3 years ago

Hey guys! I've been observing the conversation, however, I've been busy for a while, so couldn't help in anything. Borrowing from @Kevin-Mok's idea, using Cobra's man page creation for generating documentation of all the commands, and then inserting them with version/date in a template should suffice our use case.

dominikbraun commented 3 years ago

@obnoxiousnerd Do you have experience in creating those man pages using Cobra? It looks pretty good to me and we really need man pages. 🤔

retronav commented 3 years ago

I have experience of only reading man pages 😅. But creating them seems doable by looking at the API. I'll try.

retronav commented 3 years ago

Sorry, it's taking longer than expected. But hope we'll get this done. 🙂

retronav commented 2 years ago

I am close to generating the type of man pages we need, but I can't figure out what to put in the GenManHeader struct (https://pkg.go.dev/github.com/spf13/cobra/doc#GenManHeader). Can I get some help? 😅

dominikbraun commented 2 years ago

I am close to generating the type of man pages we need, but I can't figure out what to put in the GenManHeader struct (https://pkg.go.dev/github.com/spf13/cobra/doc#GenManHeader). Can I get some help? 😅

@obnoxiousnerd I'd suggest to just set the Title field with timetrace as value and see what the result looks like (I neither know what we should use as Section field here) 😄

retronav commented 2 years ago

Check out this script:

package main

import (
    "log"

    "github.com/dominikbraun/timetrace/cli"
    "github.com/dominikbraun/timetrace/config"
    "github.com/dominikbraun/timetrace/core"
    "github.com/dominikbraun/timetrace/fs"
    "github.com/spf13/cobra/doc"
)

var version = "UNDEFINED"

func main() {
    timetraceStub := core.New(&config.Config{}, &fs.Fs{})
    cmd := cli.RootCommand(timetraceStub, version)
    err := doc.GenMarkdownTree(cmd, "./docs/markdown")
    if err != nil {
        log.Fatalf("Could not generate markdown docs: %v\n", err)
    }
    err = doc.GenManTree(cmd, &doc.GenManHeader{Title: cmd.Name(), Section: "1"}, "./docs/man")
    if err != nil {
        log.Fatalf("Could not generate man docs: %v\n", err)
    }
}

This works fairly well, but try running this and inspect the output since I don't really know how the docs should be.