Skip to content

Commit

Permalink
Unify call args for addons install/update/uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
katyukha committed Apr 2, 2023
1 parent 2d804f8 commit 72b0e15
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions subpackages/cli/source/odood/cli/commands/addons.d
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CommandAddonsUpdate: OdoodCommand {
if (args.flag("all"))
project.addons.updateAll(db);
else
project.addons.update(addons, db);
project.addons.update(db, addons);
}

if (start_again)
Expand Down Expand Up @@ -300,7 +300,7 @@ class CommandAddonsInstall: OdoodCommand {
}

foreach(db; dbnames) {
project.addons.install(addons, db);
project.addons.install(db, addons);
}

if (start_again)
Expand Down Expand Up @@ -360,7 +360,7 @@ class CommandAddonsUninstall: OdoodCommand {
}

foreach(db; dbnames) {
project.addons.uninstall(addons, db);
project.addons.uninstall(db, addons);
}

if (start_again)
Expand Down
2 changes: 1 addition & 1 deletion subpackages/cli/source/odood/cli/commands/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CommandDatabaseCreate: OdoodCommand {
}

if (!to_install.empty) {
project.addons.install(to_install, dbname);
project.addons.install(dbname, to_install);
}

}
Expand Down
40 changes: 20 additions & 20 deletions subpackages/lib/source/odood/lib/addons/manager.d
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ struct AddonManager {
* if needed. Used by openupgrade.
**/
private void _run_install_update_addons(
in string[] addon_names,
in string database,
in string[] addon_names,
in cmdIU cmd,
in string[string] env) const {

Expand Down Expand Up @@ -275,43 +275,43 @@ struct AddonManager {
* search_path = path to search addons to update
**/
void update(
in OdooAddon[] addons,
in string database,
in OdooAddon[] addons,
in string[string] env=null) const {
if (!addons) {
warning("No addons specified for 'update'.");
return;
}
_run_install_update_addons(
addons.map!(a => a.name).array, database, cmdIU.update, env);
database, addons.map!(a => a.name).array, cmdIU.update, env);
}

/// ditto
void update(
in string database,
in string[] addons...) {
update(addons.map!((a) => getByName(a).get).array, database);
update(database, addons.map!((a) => getByName(a).get).array);
}

/// ditto
void update(
in string database,
in string[] addons,
in string[string] env) {
update(addons.map!((a) => getByName(a).get).array, database, env);
update(database, addons.map!((a) => getByName(a).get).array, env);
}

/// ditto
void update(
in Path search_path,
in string database,
in Path search_path,
in string[string] env=null) const {
update(scan(search_path), database, env);
update(database, scan(search_path), env);
}

/// Update all odoo addons for specific database
void updateAll(in string database, in string[string] env=null) const {
_run_install_update_addons(["all"], database, cmdIU.update, env);
_run_install_update_addons(database, ["all"], cmdIU.update, env);
}

/** Install odoo addons
Expand All @@ -323,38 +323,38 @@ struct AddonManager {
* search_path = path to search addons to install
**/
void install(
in OdooAddon[] addons,
in string database,
in OdooAddon[] addons,
in string[string] env=null) {
if (!addons) {
warning("No addons specified for 'install'.");
return;
}
_run_install_update_addons(
addons.map!(a => a.name).array, database, cmdIU.install, env);
database, addons.map!(a => a.name).array, cmdIU.install, env);
}

/// ditto
void install(
in string database,
in string[] addons...) {
install(addons.map!((a) => getByName(a).get).array, database);
install(database, addons.map!((a) => getByName(a).get).array);
}

/// ditto
void install(
in string database,
in string[] addons,
in string[string] env) {
install(addons.map!((a) => getByName(a).get).array, database, env);
install(database, addons.map!((a) => getByName(a).get).array, env);
}

/// ditto
void install(
in Path search_path,
in string database,
in Path search_path,
in string[string] env=null) {
install(scan(search_path), database, env);
install(database, scan(search_path), env);
}

/** Unnstall odoo addons
Expand All @@ -366,12 +366,12 @@ struct AddonManager {
* search_path = path to search addons to uninstall
**/
void uninstall(
in OdooAddon[] addons,
in string database,
in OdooAddon[] addons,
in string[string] env=null) {
_run_install_update_addons(
addons.map!(a => a.name).array,
database,
addons.map!(a => a.name).array,
cmdIU.uninstall,
env);
}
Expand All @@ -380,23 +380,23 @@ struct AddonManager {
void uninstall(
in string database,
in string[] addons...) {
uninstall(addons.map!((a) => getByName(a).get).array, database);
uninstall(database, addons.map!((a) => getByName(a).get).array);
}

/// ditto
void uninstall(
in string database,
in string[] addons,
in string[string] env) {
uninstall(addons.map!((a) => getByName(a).get).array, database, env);
uninstall(database, addons.map!((a) => getByName(a).get).array, env);
}

/// ditto
void uninstall(
in Path search_path,
in string database,
in Path search_path,
in string[string] env=null) {
uninstall(scan(search_path), database, env);
uninstall(database, scan(search_path), env);
}

/// Download from odoo apps
Expand Down

0 comments on commit 72b0e15

Please sign in to comment.