ipfs/kubo

helptext for all commands

Open

#2,647 创建于 2016年5月10日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)Go (2,725 fork)batch import
exp/novicehelp wantedtopic/docs-ipfs

仓库指标

Star
 (13,906 star)
PR 合并指标
 (平均合并 4天 2小时) (30 天内合并 28 个 PR)

描述

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.

贡献者指南