Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Man Page #136

Open
satiowadahc opened this issue Jun 22, 2021 · 12 comments
Open

Man Page #136

satiowadahc opened this issue Jun 22, 2021 · 12 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@satiowadahc
Copy link

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
Copy link
Author

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
Copy link

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

@satiowadahc
Copy link
Author

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
Copy link

Kevin-Mok commented Jun 22, 2021

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
Copy link
Owner

@aligator PTAL

@dominikbraun dominikbraun added enhancement New feature or request help wanted Extra attention is needed labels Jun 22, 2021
@retronav
Copy link
Contributor

retronav commented Aug 1, 2021

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
Copy link
Owner

@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
Copy link
Contributor

retronav commented Aug 3, 2021

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

@retronav
Copy link
Contributor

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

@retronav
Copy link
Contributor

retronav commented Sep 6, 2021

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
Copy link
Owner

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
Copy link
Contributor

retronav commented Sep 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants