|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/spf13/cobra" |
| 5 | + |
| 6 | + "github.com/supermodeltools/cli/internal/archdocs" |
| 7 | + "github.com/supermodeltools/cli/internal/config" |
| 8 | +) |
| 9 | + |
| 10 | +func init() { |
| 11 | + var opts archdocs.Options |
| 12 | + |
| 13 | + c := &cobra.Command{ |
| 14 | + Use: "arch-docs [path]", |
| 15 | + Short: "Generate static architecture documentation for a repository", |
| 16 | + Long: `Generate a static HTML site documenting the architecture of a codebase. |
| 17 | +
|
| 18 | +The command uploads the repository to the Supermodel API, converts the |
| 19 | +returned code graph to markdown, and builds a browsable static site with |
| 20 | +search, dependency graphs, taxonomy navigation, and SEO metadata. |
| 21 | +
|
| 22 | +The output directory can be served locally or deployed to any static host |
| 23 | +(GitHub Pages, Vercel, Netlify, Cloudflare Pages, etc.). |
| 24 | +
|
| 25 | +Examples: |
| 26 | + supermodel arch-docs |
| 27 | + supermodel arch-docs ./my-project --output ./docs-site |
| 28 | + supermodel arch-docs --repo owner/repo --base-url https://owner.github.io/repo |
| 29 | + supermodel arch-docs --site-name "My App Docs" --output /var/www/html`, |
| 30 | + Args: cobra.MaximumNArgs(1), |
| 31 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | + cfg, err := config.Load() |
| 33 | + if err != nil { |
| 34 | + return err |
| 35 | + } |
| 36 | + if err := cfg.RequireAPIKey(); err != nil { |
| 37 | + return err |
| 38 | + } |
| 39 | + dir := "." |
| 40 | + if len(args) > 0 { |
| 41 | + dir = args[0] |
| 42 | + } |
| 43 | + return archdocs.Run(cmd.Context(), cfg, dir, opts) |
| 44 | + }, |
| 45 | + } |
| 46 | + |
| 47 | + c.Flags().StringVar(&opts.SiteName, "site-name", "", "display title for the generated site (default: \"<repo> Architecture Docs\")") |
| 48 | + c.Flags().StringVar(&opts.BaseURL, "base-url", "", "canonical base URL where the site will be hosted (default: https://example.com)") |
| 49 | + c.Flags().StringVar(&opts.Repo, "repo", "", "GitHub repo slug owner/repo used to build source links") |
| 50 | + c.Flags().StringVarP(&opts.Output, "output", "o", "", "output directory for the generated site (default: ./arch-docs-output)") |
| 51 | + c.Flags().StringVar(&opts.TemplatesDir, "templates-dir", "", "override bundled HTML/CSS/JS templates with a custom directory") |
| 52 | + c.Flags().IntVar(&opts.MaxSourceFiles, "max-source-files", 3000, "maximum source files to include in analysis (0 = unlimited)") |
| 53 | + c.Flags().IntVar(&opts.MaxEntities, "max-entities", 12000, "maximum entity pages to generate (0 = unlimited)") |
| 54 | + c.Flags().BoolVar(&opts.Force, "force", false, "bypass cache and re-upload even if a cached result exists") |
| 55 | + |
| 56 | + rootCmd.AddCommand(c) |
| 57 | +} |
0 commit comments