Go-ipfs: helptext for all commands

Created on 10 May 2016  路  6Comments  路  Source: ipfs/go-ipfs

I would love to add a test like this to the codebase:

package commands

import (
    cmds "github.com/ipfs/go-ipfs/commands"
    "strings"
    "testing"
)

func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
    if c.Helptext.Tagline == "" {
        t.Fatalf("%s has no tagline!", strings.Join(name, " "))
    }

    if c.Helptext.LongDescription == "" {
        t.Fatalf("%s has no long description!", strings.Join(name, " "))
    }

    if c.Helptext.ShortDescription == "" {
        t.Fatalf("%s has no short description!", strings.Join(name, " "))
    }

    if c.Helptext.Synopsis == "" {
        t.Fatalf("%s has no synopsis!", strings.Join(name, " "))
    }

    for subname, sub := range c.Subcommands {
        checkHelptextRecursive(t, append(name, subname), sub)
    }
}

func TestHelptexts(t *testing.T) {
    checkHelptextRecursive(t, []string{"ipfs"}, Root)
}

But right now it would just fail, lots of commands are missing various pieces of the helptext. Enforcing this would make our docs muuuuuch better i think. We would also be able to generate manpages easily from them.

dieasy help wanted topidocs-ipfs

Most helpful comment

@RichardLitt Yeah, i started working on some code to generate man pages yesterday but most of the commands didnt have everything filled out so they were pretty underwhelming

All 6 comments

@whyrusleeping Can you add it in a branch, and I can go through the CI and fix them all?

sure thing, but instead of going through ci, just pull the branch down and run go test ./core/commands

Works for me! I think this is a great move, happy to do this.

@RichardLitt Yeah, i started working on some code to generate man pages yesterday but most of the commands didnt have everything filled out so they were pretty underwhelming

I am unlikely to get to this soon. I would suggest unassigning this and labeling at as 'help wanted'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kallisti5 picture kallisti5  路  3Comments

magik6k picture magik6k  路  3Comments

jonchoi picture jonchoi  路  3Comments

zignig picture zignig  路  3Comments

daviddias picture daviddias  路  3Comments