chhoumann / quickadd

QuickAdd for Obsidian
https://quickadd.obsidian.guide
MIT License
1.5k stars 136 forks source link

[FEATURE REQUEST] allow scripts with settings to export multiple functions #498

Open skewballfox opened 1 year ago

skewballfox commented 1 year ago

Is your feature request related to a problem? Please describe. This might be a situation where the docs are poorly covering an existing feature, but it would be useful to allow for multiple exported functions sharing the same settings.

Describe the solution you'd like a method to export two (or more) functions sharing a settings object. if you attempt to specify the function name as hinted at in the second section of Macro choice you get the error <script_name>::<exportedFunction> has no settings

Additional context here's the script I'm currently trying to get working:

const LIST_PATH = "Path to the list of blog titles";
const settings = {
    name: "Blog Tool",
    author: "skewballfox",
    options: {
        [LIST_PATH]: {
            type: "text",
            defaultValue: "",
            placeholder: "path/to/blogs.json"
        }
    }
}
module.exports = {
    entry: addBlog, settings
};
module.exports = {
    entry: selectRandomBlog, settings
};
...

(switched to this after realizing entry is a required keyword, was using something like

module.exports = {
    addBlog, selectRandomBlog, settings
};

The first one prompts the user and adds a blog title to a json file, the second "pops" a random title from the array and creates a file from a template. I was considering adding a third where you can select a blog to be worked on. I'd rather handle these cases within the script because of the deletion of entries