Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate system flag for registration, use cache instead #2791

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -2339,8 +2339,8 @@ abstract class RegistrationCommand : Command {
override void prepare(scope CommandArgs args)
{
args.getopt("system", &m_system, [
"Register system-wide instead of user-wide"
]);
"DEPRECATED: Use --cache=system instead"
], true);
}

abstract override int execute(Dub dub, string[] free_args, string[] app_args);
Expand All @@ -2367,7 +2367,12 @@ class AddPathCommand : RegistrationCommand {
override int execute(Dub dub, string[] free_args, string[] app_args)
{
enforceUsage(free_args.length == 1, "Missing search path.");
dub.addSearchPath(free_args[0], m_system);
enforceUsage(!this.m_system || dub.defaultPlacementLocation == PlacementLocation.user,
"Cannot use both --system and --cache, prefer --cache");
if (this.m_system)
dub.addSearchPath(free_args[0], PlacementLocation.system);
else
dub.addSearchPath(free_args[0], dub.defaultPlacementLocation);
return 0;
}
}
Expand All @@ -2384,7 +2389,12 @@ class RemovePathCommand : RegistrationCommand {
override int execute(Dub dub, string[] free_args, string[] app_args)
{
enforceUsage(free_args.length == 1, "Expected one argument.");
dub.removeSearchPath(free_args[0], m_system);
enforceUsage(!this.m_system || dub.defaultPlacementLocation == PlacementLocation.user,
"Cannot use both --system and --cache, prefer --cache");
if (this.m_system)
dub.removeSearchPath(free_args[0], PlacementLocation.system);
else
dub.removeSearchPath(free_args[0], dub.defaultPlacementLocation);
return 0;
}
}
Expand All @@ -2406,9 +2416,16 @@ class AddLocalCommand : RegistrationCommand {

override int execute(Dub dub, string[] free_args, string[] app_args)
{
enforceUsage(free_args.length == 1 || free_args.length == 2, "Expecting one or two arguments.");
enforceUsage(free_args.length == 1 || free_args.length == 2,
"Expecting one or two arguments.");
enforceUsage(!this.m_system || dub.defaultPlacementLocation == PlacementLocation.user,
"Cannot use both --system and --cache, prefer --cache");

string ver = free_args.length == 2 ? free_args[1] : null;
dub.addLocalPackage(free_args[0], ver, m_system);
if (this.m_system)
dub.addLocalPackage(free_args[0], ver, PlacementLocation.system);
else
dub.addLocalPackage(free_args[0], ver, dub.defaultPlacementLocation);
return 0;
}
}
Expand All @@ -2425,8 +2442,15 @@ class RemoveLocalCommand : RegistrationCommand {
override int execute(Dub dub, string[] free_args, string[] app_args)
{
enforceUsage(free_args.length >= 1, "Missing package path argument.");
enforceUsage(free_args.length <= 1, "Expected the package path to be the only argument.");
dub.removeLocalPackage(free_args[0], m_system);
enforceUsage(free_args.length <= 1,
"Expected the package path to be the only argument.");
enforceUsage(!this.m_system || dub.defaultPlacementLocation == PlacementLocation.user,
"Cannot use both --system and --cache, prefer --cache");

if (this.m_system)
dub.removeLocalPackage(free_args[0], PlacementLocation.system);
else
dub.removeLocalPackage(free_args[0], dub.defaultPlacementLocation);
return 0;
}
}
Expand Down
36 changes: 32 additions & 4 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,17 @@ class Dub {

See_Also: `removeLocalPackage`
*/
deprecated("Use `addLocalPackage(string, string, PlacementLocation)` instead")
void addLocalPackage(string path, string ver, bool system)
{
this.addLocalPackage(path, ver, system ? PlacementLocation.system : PlacementLocation.user);
}

/// Ditto
void addLocalPackage(string path, string ver, PlacementLocation loc)
{
if (m_dryRun) return;
m_packageManager.addLocalPackage(makeAbsolute(path), ver, system ? PlacementLocation.system : PlacementLocation.user);
this.m_packageManager.addLocalPackage(makeAbsolute(path), ver, loc);
}

/** Removes a directory from the list of locally known packages.
Expand All @@ -1121,10 +1128,17 @@ class Dub {

See_Also: `addLocalPackage`
*/
deprecated("Use `removeLocalPackage(string, string, PlacementLocation)` instead")
void removeLocalPackage(string path, bool system)
{
this.removeLocalPackage(path, system ? PlacementLocation.system : PlacementLocation.user);
}

/// Ditto
void removeLocalPackage(string path, PlacementLocation loc)
{
if (m_dryRun) return;
m_packageManager.removeLocalPackage(makeAbsolute(path), system ? PlacementLocation.system : PlacementLocation.user);
this.m_packageManager.removeLocalPackage(makeAbsolute(path), loc);
}

/** Registers a local directory to search for packages to use for satisfying
Expand All @@ -1137,10 +1151,17 @@ class Dub {

See_Also: `removeSearchPath`
*/
deprecated("Use `addSearchPath(string, PlacementLocation)` instead")
void addSearchPath(string path, bool system)
{
this.addSearchPath(path, system ? PlacementLocation.system : PlacementLocation.user);
}

/// Ditto
void addSearchPath(string path, PlacementLocation loc)
{
if (m_dryRun) return;
m_packageManager.addSearchPath(makeAbsolute(path), system ? PlacementLocation.system : PlacementLocation.user);
this.m_packageManager.addSearchPath(makeAbsolute(path), loc);
}

/** Deregisters a local directory search path.
Expand All @@ -1152,10 +1173,17 @@ class Dub {

See_Also: `addSearchPath`
*/
deprecated("Use `removeSearchPath(string, PlacementLocation)` instead")
void removeSearchPath(string path, bool system)
{
this.removeSearchPath(path, system ? PlacementLocation.system : PlacementLocation.user);
}

/// Ditto
void removeSearchPath(string path, PlacementLocation loc)
{
if (m_dryRun) return;
m_packageManager.removeSearchPath(makeAbsolute(path), system ? PlacementLocation.system : PlacementLocation.user);
this.m_packageManager.removeSearchPath(makeAbsolute(path), loc);
}

/** Queries all package suppliers with the given query string.
Expand Down
Loading