Package: lordcommander
LordCommanderLordCommander is a command line program to run shell commands recursively through predefined directories.See fullchangelog here.ContentsDependenciesInstallationUpgrading from v4.x to v5.xUsageProject handlingSee project listAdd new projectSet/Change active projectRemove a projectRename a projectDirectory/Instance handlingSee directory listAdding directoriesRemoving directoriesRunning commandsThrottled executionExclude directories from executionRun only for specified directoriesUtilitiesSearching for a directorySee total number of directoriesDumping and restoring dataDependencies^Python 3.7.5Python FireColrInstallationRun following command to install LordCommander:pip install lordcommanderIt will be available aslcin your environment, and you can run commands like:lc<command><args><flags>Upgrading from v4.x to v5.xSince version 5.x  LordCommander will be a python package instead of individual project and the data directory is changed as a standard package should behave. Here is how you should upgrade to 5.x:First, take a backup of your data./lcutilsdump~/It would create alcdb_dump.jsonfile in your home directory. After that, remove existingLordCommanderfolder and install it using pip. Henceforth, you can restore data using the backup file just as before. The commands remain same.UsageHow to run commands using LordCommander?Add some projects to LordCommander.Set a project as active.Add some instances of that project.Run a command.You can append--helpafter each command always to see the manual.Project HandlingSee project listTo see added projects to LordCommander, run:lc proj viewThe active project will be check marked.Add new projectTo add a new project, you have to specify the path of the project directory. Usually the last part of the path is taken as the project name but you can specify a custom name for the project using the--nameflag.Remember, this is not the location of individual project, i.e. directories where the command will run are inside this location.Run:lc proj add /home/sowrensen/test/project-a --name=customnameThis will create the following data structure in the shelve module:'customname': {
    'root': '/home/sowrensen/test/project-a',
    'instances': []
}Without the--nameflag, it will be,'project-a': {
    'root': '/home/sowrensen/test/project-a',
    'instances': []
}Later in theinstanceslist, you will add your project instances usingdirs addcommand.Set or change active projectTo set or change active project, you must have at least one project. After adding projects, run:lc proj active project-aRemove a projectTo remove a project from LordCommander, run:lc proj clear project-aThe program will ask for your confirmation, if you allow it will remove entire project along with it's added instances. If a project is set as active during removal, theactivekey will set to null and you have to set an active project for further operations.Rename a projectTo rename a project, run:lc proj rename oldname newnameIf the project you renaming are the one currently marked as active, it will automatically update the name of the active project.Directory/Instance HandlingSee directory listlc dirs viewThis will show all saved directory names with the index as their insertion order. To sort directory names alphabetically, appendsortor--sortafter list.lc dirs view [sort|--sort]Adding directorieslc dirs add [dir1 dir2 dir3...]All the directory names afteraddkeyword will be appended to the directory list.Removing directorieslc dirs clear [dir1 dir2 dir3...]Add desired directory names afterclearto remove them from list. However, you can also clear the entire list of directories if you specify--fullafterclear.lc dirs clear --fullIt will ask for your confirmation, if you allow, it will remove the entire list of directories.Running CommandsRunning a command throughout the saved directories is easy. Here's an example:lc run pwdThat's it! It will recursively run for each saved directories and show the output.  Afterwards, you will see the number of successful and failed runs.Note:If your command is more than one word, you have to wrap it around with single or double quote. An example can belc run 'git status'.Throttled executionNow, if you have a huge list of directories and you don't want to run the command altogether,  you can slice them by indices (I assume that you're familiar with how array or list index works). If you runlc run --helpyou will see two flags--liand--uirespectively forlower indexandupper index. So if you decide to run a command only to first 50 directories, you can simply specify--li=0and--ui=50. Or even simpler, just mention--ui=50, it will run throughout index 0 to index 49 anyway.lc run <command> --li=0 --ui=50or,lc run <command> 0 50or,lc run <command> --ui=50So for running the rest? I bet you already figured that out,lc run <command> --li=50or,lc run <command> 50Yes, you don't have to remember or know how any items are in your list. Just tell the program to run it from 50 and it will start right there and won't stop until it reaches the end of the list.Exclude directory/instance from executionTo exclude one or more particular directories/instances from execution, you can specify indices with--exflag. e.g.:lc run <command> --ex=3,8Thus, directories in index 3 and 8 will be excluded from the list during execution.Run only for specified directoriesLike exclusion, you only can run a command for desired instances. Add--incflag with indices for that, e.g.:lc run <command> --inc=3,8The command will run for index 3 and 8 only.NOTE: The--exand the--incflag takes precedence overliandui. That is to say, if you use--exwithliandui, indices specified will beexcluded. And in case of--inc,only for instances within the indicesthe command will run. Also, you should not use--exand--inctogether.UtilitiesFrom version 3.0, a utility class has been added to run some handy tasks. Right now there are four commands, more will be introduced over time.Searching for a directoryForgot if a directory name has already been included or not? Just tell the program to look for it, it will tell you if it is there or not.lc utils search <directory_name>Note: It is case sensitive, so if you have a directory namedABCand your search string isabc, you will get a negative result.Seeing total number of directoriesIf you're wondering how many saved directories do you have, just tell LordCommander to count them for you:lc utils totalDumping and restoring data using JSON fileWith version 4.0, you can dump and restore data of LordCommander. To dump existing data in the shelve module, run:lc utils dump /home/sowrensenThe third argument is the location where you want to save the file. There you will find a file namedlcdb_dump.json. You can use that file later to restore data into shelve module. To restore from a JSON file, run following command with the file path as third argument.Note:Restoring data will replace existing data. It is a good idea to dump before you restore.lc utils restore /home/sowrensen/lcdb_dump.json