feat: add prop clone command
This commit is contained in:
@@ -44,6 +44,22 @@ func CommandPropertySet(pluginName, appName, property, value string, properties
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PropertyClone clones a set of properties from one app to another
|
||||||
|
func PropertyClone(pluginName string, oldAppName string, newAppName string) error {
|
||||||
|
properties, err := PropertyGetAll(pluginName, oldAppName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for property, value := range properties {
|
||||||
|
if err := PropertyWrite(pluginName, newAppName, property, value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// PropertyDelete deletes a property from the plugin properties for an app
|
// PropertyDelete deletes a property from the plugin properties for an app
|
||||||
func PropertyDelete(pluginName string, appName string, property string) error {
|
func PropertyDelete(pluginName string, appName string, property string) error {
|
||||||
propertyPath := getPropertyPath(pluginName, appName, property)
|
propertyPath := getPropertyPath(pluginName, appName, property)
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ fn-plugin-property-get() {
|
|||||||
fn-plugin-property-get-default "$PLUGIN" "$APP" "$KEY" "$DEFAULT"
|
fn-plugin-property-get-default "$PLUGIN" "$APP" "$KEY" "$DEFAULT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn-plugin-property-clone() {
|
||||||
|
declare desc="destroy the properties for an app"
|
||||||
|
declare PLUGIN="$1" OLD_APP="$2" NEW_APP="$3"
|
||||||
|
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" "clone" "$PLUGIN" "$OLD_APP" "$NEW_APP"
|
||||||
|
}
|
||||||
|
|
||||||
fn-plugin-property-destroy() {
|
fn-plugin-property-destroy() {
|
||||||
declare desc="destroy the properties for an app"
|
declare desc="destroy the properties for an app"
|
||||||
declare PLUGIN="$1" APP="$2"
|
declare PLUGIN="$1" APP="$2"
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ func main() {
|
|||||||
pluginName := flag.Arg(1)
|
pluginName := flag.Arg(1)
|
||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
case "clone":
|
||||||
|
oldAppName := flag.Arg(2)
|
||||||
|
newAppName := flag.Arg(3)
|
||||||
|
err := common.PropertyClone(pluginName, oldAppName, newAppName)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
case "del":
|
case "del":
|
||||||
appName := flag.Arg(2)
|
appName := flag.Arg(2)
|
||||||
property := flag.Arg(3)
|
property := flag.Arg(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user