mudrd8mz / moodle-tool_pluginskel

Generator of Moodle plugins skeletons
https://moodle.org/plugins/tool_pluginskel
Other
51 stars 46 forks source link

Target location for the generated files #22

Closed alexandru-elisei closed 8 years ago

alexandru-elisei commented 8 years ago

Last we discussed about this we agreed that we should allow the user to specify a target location for the generated files.

After looking at the manager::init_target_location() function it seems to me that you want the user to specify a target directory and in that target directory you are going to build the entire Moodle hierarchy for the plugin directory. For example, if $moodleroot = /home/david and the component is local_name then the target directory for the files will be /home/david/local/name/.

Is this what you want?

I propose that we create the function public function write_files($moodleroot = null) which will call init_target_location($moodleroot), then it will generate all the plugin files in the directory specified by $this->rootdir.

mudrd8mz commented 8 years ago

Firstly, init_target_location() is actually a relic that is not currently used. And I am not quite sure about what we want. I see two basic use cases:

The main cli/generate.php could support both scenarios via two alternative arguments:

Normally just one of the two options would be provided. If both options would be provided leading to different locations, exception would be thrown. If no location would be provided, the script would assume --target-moodle set to $CFG->dirroot of its own Moodle instance.

alexandru-elisei commented 8 years ago

So:

  1. php generate.php --target-moodle means that the files will be created in the default location within the moodle installation directory.
  2. php generate.php --target-dir=/test means that the plugin files will be created at /test/pluginname
  3. php generate.php is the same as the 1.
  4. php generate.php --target-dir=/test --target-moodle throws an exception
  5. php generate.php --target-dir=/path/to/moodle/root --target-moodle is legal.

Have I understood correctly?

mudrd8mz commented 8 years ago

Let us make it a bit simpler than I originally described: If both these params are specified, throw an error message and explain that only one of them is expected.

mudrd8mz commented 8 years ago

--target-moodle should make no assumptions on whether or not the moodle is actually installed there. In fact, it is valid to call php --target-moodle=/tmp in which case, the editor would be generated into /tmp/lib/editor/foo even if no moodle is actually present in /tmp.

alexandru-elisei commented 8 years ago

Got it, I like it.