forked from xpipe-io/xpipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
core/src/main/java/io/xpipe/core/process/ElevationConfig.java
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
core/src/main/java/io/xpipe/core/process/ElevationFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.xpipe.core.process; | ||
|
||
import io.xpipe.core.util.FailableFunction; | ||
|
||
public interface ElevationFunction { | ||
|
||
static ElevationFunction of(String prefix, FailableFunction<ShellControl, Boolean, Exception> f) { | ||
return new ElevationFunction() { | ||
@Override | ||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
@Override | ||
public boolean isSpecified() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean apply(ShellControl shellControl) throws Exception { | ||
return f.apply(shellControl); | ||
} | ||
}; | ||
} | ||
|
||
static ElevationFunction elevated(String prefix) { | ||
return new ElevationFunction() { | ||
@Override | ||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
@Override | ||
public boolean isSpecified() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean apply(ShellControl shellControl) { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
static ElevationFunction none() { | ||
return new ElevationFunction() { | ||
@Override | ||
public String getPrefix() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isSpecified() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean apply(ShellControl shellControl) { | ||
return false; | ||
} | ||
}; | ||
} | ||
|
||
String getPrefix(); | ||
|
||
boolean isSpecified(); | ||
|
||
boolean apply(ShellControl shellControl) throws Exception; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters