Skip to content

feat(added): license generation#7

Open
kushvinth wants to merge 2 commits intovg006:mainfrom
kushvinth:main
Open

feat(added): license generation#7
kushvinth wants to merge 2 commits intovg006:mainfrom
kushvinth:main

Conversation

@kushvinth
Copy link

Feat(License): Add Interactive License Generation to Project Initialisation

Overview

Added comprehensive license generation functionality to vgo CLI, allowing users to select and generate licenses directly during project initialisation with GitHub API integration. Inspired from lic

Demo

CleanShot.2026-01-15.at.08.45.52.mp4

@vg006
Copy link
Owner

vg006 commented Jan 15, 2026

@kushvinth Thank you for your contribution!

The tool lic is really helpful for adding licenses to project. Offering similar feature in vgo is a good proposal.

I tested your changes locally and satisfied with it. Will merge this PR shortly after few revisions.

@kushvinth
Copy link
Author

PS: we also need to re-do the video on the readme

@vg006
Copy link
Owner

vg006 commented Jan 15, 2026

Yeah it is noted, that will be covered too.

@vg006
Copy link
Owner

vg006 commented Jan 17, 2026

@kushvinth
Once again I have gone through your proposal, tested them locally, iterated several times and here's what I find.

  1. Most of the licenses (except MIT, BSD) doesn't have placeholders for author's or project's info. So there's no use to have those input fields for them.
  2. The latency of licenses list fetch call extends from milliseconds to a few seconds sometimes. Also we can fetch the licenses asynchronously using separate goroutine, instead on bootstrap.
  3. Fallback to the default set of licenses is good, but if we do so, then we just define the set of licenses as a list, instead of making a call for it.
  4. Also vgo is designed to be offline-first and fast, but these network calls introduces latency and unfortunately error in scaffold sometimes, reduces reliability.

Anyways, vgo is planned to support custom templates like nix templates, which obviously involves network calls, but as of now, I suggest to add the licenses templates into the templates rather.

Since the open source licenses are definite, versioned and stable, we can add those templates and find no good reason to have network calls.

Currently, the binary size is about ~13MB and the existing templates around ~92KB, which is about 0.007% of the total, which is negligible. Now, the license templates alone are estimated of size ~100KB in total, which doesn't have significant impact on binary size.

So these are my suggestions.

licenses, fetchErr = license.FetchLicenses()
if fetchErr != nil {
// If fetch fails, provide some basic options
licenses = []license.GitHubLicense{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the keys are definite and known, we don't need a fetch call here and better skip it.

Description("Select a license for the project").
Options(licenseOptions...),
),
huh.NewGroup(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditionally can have this input group

}

// GetGitUsername retrieves the git user.name from global config
func GetGitUsername() string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

// RenderLicense replaces placeholders in license content with actual values
func RenderLicense(content, author, year string) string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

// FetchLicenses retrieves the list of available licenses from GitHub API
func FetchLicenses() ([]GitHubLicense, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this

}

// GetLicenseContent retrieves the full license content from GitHub API
func GetLicenseContent(key string) (string, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this

@vg006
Copy link
Owner

vg006 commented Jan 17, 2026

Can you rather create a dir licenses under this dir and add the licenses templates in there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants