How do I allow users to set configuration settings that are strings?


#1

Hi,

I have been working on my language-archlinux package, giving it the ability to create a new PKGBUILD from a template I have given it. It also attempts to fill out some basic fields in the PKGBUILD and to do so it needs the user to be able to set two configuration variables:

  • username
  • email

Now this would seem like a simple enough task (which is what I thought too at first), especially after reading the API docs (https://atom.io/docs/api/v1.8.0/Config) but it wasn’t. I have tried to allow users to set config settings by editing my main.coffee file to include:

  config:
    username:
      title: 'What name do you want to use in your PKGBUILD headers?'
      type: 'string'
      default: 'NAME'
    email:
      title: 'What email do you want to use in your PKGBUILD headers?'
      type: 'string'
      default: 'EMAIL'

but this failed to add these settings to this package’s config page (i.e., the page opened by going to Edit->Preferences and selecting this package has no mention of these two configuration variables). I have also tried (both separately and while the aforementioned edit to main.coffee has been made) adding this to the package.json file:

    "username": {
      "type": "string",
      "default": "NAME",
      "title": "Your username",
      "description": "Set the username this package will use when you create a new PKGBUILD."
    },
    "email": {
      "type": "string",
      "default": "EMAIL",
      "title": "Your spam-safe email address",
      "description": "Set the spam-safe (encoded) email address this package will use when you create a new PKGBUILD"
    }

but even after reloading Atom (keeping in mind that I have this package installed via apm linking it, so I do see updates I make to it, after reloading of course) I could not find these settings in the language-archlinux configuration settings pane.

The reason I have named this question so that it specifically refers to config variables that are strings is because I have no such problem adding configuration settings that are of the boolean variety. In the case of boolean settings merely adding something like:

    "checkPKGBUILDOnSave": {
      "type": "boolean",
      "default": false,
      "title": "Check PKGBUILD for errors on save",
      "description": "Check PKGBUILD for errors with namcap on save"
    },
    "updateCheckSumsOnSave": {
      "type": "boolean",
      "default": false,
      "title": "Update PKGBUILD checksums on save",
      "description": "Update checksums in PKGBUILD on save"
    },
    "updateSrcInfoOnSave": {
      "type": "boolean",
      "default": false,
      "title": "Update PKGBUILD SRCINFO on save",
      "description": "Update SRCINFO on save"
    },

would do the trick.

Thanks for your time,
Brenton


#2

Oops nvm I seem to have inexplicably solved this problem. Not sure how though, but now the config settings pane exists.