synesthesia-it / Murray

Easily add features to your projects by scaffolding new files with Stencil templates
MIT License
55 stars 2 forks source link

Options list for bone item parameter #57

Closed stefanomondino closed 1 month ago

stefanomondino commented 1 month ago

When running murray run on procedures containing items with multiple required parameters, it's quite easy to forget - after some time - what every parameter is intended for and, most important, what are the allowed values for it.

Parameters are getting resolved against the entire context and they might refer to common/shared resources like folder and filenames that might only assume certain values.

An example in a Swift project could be a bone that installs a File.swift file that can only go in either the Sources or the Tests folder, according to some parameter that should be provided when running the command. Providing the wrong spelling for it (like Source or Test) will result in Murray succeeding creating the file, but creating a meaningless folder.

Murray should implement the option to declare an option list in the parameters field of the item configuration. If such list is provided AND the parameters are not the ones contained in such list, then the command should fail with a meaningful message.

Example (in yml):

name: module
parameters:
- name: name
  isRequired: true
- name: moduleType
  values: ["Sources", "Tests"]
  isRequired: true

so that

murray run module TheModule moduleType:Source

will immediately stop without creating anything because "Source" is not "Sources" or "Tests"