      container_generator script
      By alvazir

Version: 2.0

=========
Contents
=========
1.    Description
2.    Requirements
3.    Limitations
4.    Changelog
5.    Credits
6.    Permissions
7.    Contact

============
Description
============
This script performs following tasks in one pass or semi-independently (controlled by switches):
1a. Scan provided list of plugings and find NPCs with Barter services
1b. Assign container (or reject to do it) from Wares-base to them
2. Create secondary scripts for making plugins with those containers instanced
3. Run generated scripts to create plugin(s)

Place it into "Morrowind/Data Files" directory and run the script with '--help' argument to get usage information. I've tried to make it fail-safe and it should not delete/mess up anything. It will refuse to run if you lack something needed for it.

My plugins are stored in other directories so I've just copied them to playground directory structured as Morrowind dir. It looks like that:
  playground_dir
    tes3cmd
    Data Files
      container_generator.sh
      Morrowind.esm
      ...

Example of command (i used it to make "Wares-base - Expansion")*:
  ./container_generator.sh --run --modular --exclude-last 
    This created Merged plugin (default action), Modular plugins (1 per original plugin), Merged plugin without the last in list (last was TR_Mainland.esm).

To adjust container assignment either:
1. Add your specific rules around line 400 of script.
2. Run only step 1 (-1), modify containers_assigned.txt as you need, then run remaining steps (-2 -3).

It's not limited to Wares-base. It just uses Wares-base's container names internally. For example I've made plugin with unique containers assigned to many publicans with the following command. Resulting plugin is not related to Wares at all:
    ./container_generator.sh --run --dir "publicans_1.0.1" --filter-cont "aa_wares_publican" --special-cont-id-mode "aspc"

You can dump the whole plugins list into it and it should work. If you use it against large files like TR_Mainland better install Ripgrep (this will speedup the process for large files). "Wares-base - Expansion" took 6 minutes with rg, would probably take 15 minutes with regular grep.

Don't hesitate to contact me if '--help' is not enough. Though I don't expect many (or anyone to be honest) to use this script. 

(*) Command was really a bit longer and not that good for example (keeping it here as a reference for myself):
  time ./container_generator.sh --run --modular --exclude-last --directory "wares-base_expansion_v1.0" --basename "Wares-base - Expansion" --html | tee script_output.log; 7z a "wares-base_expansion_v1.0.output_dir.7z" "wares-base_expansion_v1.0" "script_output.log"
  (5m41s)

=============
Requirements
=============
- bash
  - Linux/MacOS users may run it straight
  - Windows users need to install something (Bash from Git for Windows should probably be enough, or Windows Linux Subsystem etc)
- tes3cmd
  - I use 0.40 perl version from github though I suppose 0.37 packed into .exe file should work as well
- base utils like cp, mv, grep etc (should be there if you have bash)

============
Limitations
============
It will not work as desired for plugins like "Starfires NPC Additions ver-1.13.esp". NPCs there are placed via leveled lists, so the script won't find any NPC instances.

==========
Changelog
==========
1.0
  - Initial naive slow version
2.0
  - Complete rewrite to make it faster (and even faster with rg (ripgrep) installed)
    - 1.0 version took almost 2 hours to process TR_Mainland, this version takes 2 minutes
  - Add few quality-of-life things like generating html files via pandoc in addition to custom formatted txt files

========
Credits
========
- John Moonsugar: tes3cmd - this script is just a wrapper around tes3cmd
- Danae: Wares - there would be no script's purpose without Danae's brilliant work

============
Permissions
============
You can use this however you want, as long as you credit authors.

========
Contact
========
Morrowind Nexus: https://www.nexusmods.com/morrowind/users/77253     
