Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

tag generate use the add/remove tag config as the default input. #2929

Closed
czlhs opened this issue Dec 6, 2019 · 4 comments
Closed

tag generate use the add/remove tag config as the default input. #2929

czlhs opened this issue Dec 6, 2019 · 4 comments

Comments

@czlhs
Copy link

czlhs commented Dec 6, 2019

Describe the solution you'd like
use the config.tags/config.options as the default input

function getTagsAndOptions(config, commandArgs) {
    const tags = commandArgs && commandArgs.hasOwnProperty('tags') ? commandArgs['tags'] : config['tags'];
    const options = commandArgs && commandArgs.hasOwnProperty('options') ? commandArgs['options'] : config['options'];
    const promptForTags = commandArgs && commandArgs.hasOwnProperty('promptForTags') ? commandArgs['promptForTags'] : config['promptForTags'];
    const transformValue = commandArgs && commandArgs.hasOwnProperty('transform') ? commandArgs['transform'] : config['transform'];
    if (!promptForTags) {
        return Promise.resolve([tags, options, transformValue]);
    }
    return vscode.window.showInputBox({
        value: tags, // change to config.tags, but not 'json'
        prompt: 'Enter comma separated tag names'
    }).then(inputTags => {
        return vscode.window.showInputBox({
            value: options, // change to config.options, but not 'json,omitempty...'
            prompt: 'Enter comma separated options'
        }).then(inputOptions => {
            return [inputTags, inputOptions, transformValue];
        });
    });
}
@ramya-rao-a
Copy link
Contributor

Thanks for reporting @czlhs

PRs are most welcome to make this change.

@ramya-rao-a
Copy link
Contributor

Thanks for the PR @Ashniu123

The change here should be available in the latest beta version of this extension. Please try it out and let us know how it goes

@ramya-rao-a
Copy link
Contributor

The latest version of this extension (0.12.0) has this feature now.

Thanks to @czlhs for reporting and to @Ashniu123 for the PR :)

Happy Coding!

@tangx
Copy link

tangx commented Dec 31, 2019

for comment

setting.json

    "go.addTags": {
        "tags": "yaml,json",
        "options": "yaml=omitempty,yaml=options2,yaml=options3,json=omitempty",
        "promptForTags": false,
        "transform": "snakecase"
    },
  • result
type Person struct {
	Name   string `yaml:"name,omitempty,options2,options3" json:"name,omitempty"`
	Age    int    `yaml:"age,omitempty,options2,options3" json:"age,omitempty"`
	Gender string `yaml:"gender,omitempty,options2,options3" json:"gender,omitempty"`
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants