# Expose (document) \`Pkg.generate\` API for programmatic usage

**URL:** <https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115>\
**Category:** General Usage\
**Created:** [July 7, 2019, 1:52pm UTC](https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115 "2019-07-07T13:52:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [July 7, 2019, 1:52pm UTC](https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115/1 "2019-07-07T13:52:16Z")

</div>

I don’t know if this is on the roadmap but I’d like to encourage documenting and exposing the `Pkg.generate` API for programmatic usage. Recently I’ve been working on adding a plugins interface for `Genie`, and part of it I provide a scaffolding method. A plugin is a Julia package with some `Genie` interfaces - so scaffolding involves creating this Julia package and then setting up some files and a certain folder structure within the package.

However, without a clear API it’s hard to make progress and I don’t want to hack things at file level as that’s brittle and undocumented and can break with changes in `Pkg`. For instance:

1. I run `Pkg.generate("$user_provided_plugin_name")` - how do I programatically retrieve the name of the module and the location of the generated file(s) (what if the user inputs spaces, dashes, casing, etc.)?

2. I would like to pre-populate the generated `module` file with the interfaces to help the devs. A newly generated module within a package now has a `greet()` method and a closing `end # module` line. I could search for either of these and write my code around them - but these could change at any time, breaking my code.

What’s the best way to solve these problems?

I’ve been looking at `PackageSpec` but it doesn’t appear to work with `Pkg.generate`? Also, `PackageSpec` would have to support a user inputted template instead of the default `greet()`.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 7, 2019, 7:32pm UTC](https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115/2 "2019-07-07T19:32:05Z")

</div>

This is tangential to the `Pkg.generate` API, but for your use, maybe a custom template or plugin for [PkgTemplates.jl](https://github.com/invenia/PkgTemplates.jl) might work?

---

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [July 8, 2019, 5:34am UTC](https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115/3 "2019-07-08T05:34:53Z")

</div>

Ah, that’s pretty cool, thank you. I wasn’t aware of `PkgTemplates`, seems that it could be quite useful!

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 8, 2019, 9:46am UTC](https://discourse.julialang.org/t/expose-document-pkg-generate-api-for-programmatic-usage/26115/4 "2019-07-08T09:46:12Z")

</div>

I have thought about deprecating `Pkg.generate` and just point to PkgTemplates instead. It does almost nothing and is mostly for the Pkg tests itself to use.
