Skip to content

Zuzzuc/PlistKeyMod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 

Repository files navigation

PlistKeyMod

PlistKeyMod.sh is used to both extract and modify the values of specific keys in a plist file.

Usage

Examples

/PlistKeyMod.sh -f="$HOME/Desktop/example.plist" -k="CFBundleName"
This will return the value of the key "CFBundleName".'

/PlistKeyMod.sh -f="$HOME/Desktop/example.plist" -k="CFBundleName" -m="write" -v="Example"
This will change the value of the key "CFBundleName" to "Example"

Arguments

File

-f or --file

Requires a parameter

This option is REQUIRED for this script to work.


This option chooses what file to perform actions on.

Example: /PlistKeyMod.sh -f=example.plist


Key

-k or --key

Requires a parameter

This option is REQUIRED for this script to work.


This option chooses what key to perform actions on.

Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName


Mode

-m or --mode

Requires a parameter

This option will default to 'read' if not set.


This option chooses what mode to use when performing actions on a file.
Available modes: 'read' and 'write'

If the mode is 'write', use -v to choose what to write.

Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=read


Value

-v or --value

This option is REQUIRED if mode is set to 'write'


This option chooses what value to assign a key if mode is set to 'write'.

Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=write -value=StringToAssign


Output

-o or --output

Requires a parameter

This option will default to 'auto' if not supplied.


This option chooses where to send the result.

There are three modes that the output option can handle. These are 'auto', 'STDIN', and 'filepath'

The option 'auto' will print the result to stdin if the mode is read and will edit the file if the mode is write. The option 'STDIN' will cause any result to be printed to stdin, even if the mode is write. The last option is dynamic. Any absolute filepath ented will cause the script to print all result, except error messages, to the supplied path.


Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=write -v=StringToAssign -o=STDIN
This will cause the whole plist file to be returened to stdin, but with changes made.

Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=read -o=/tmp/result.txt
This will send the value of the key 'CFBundleName' to a file in /tmp/result.txt

Exit codes

0: Success
1: No file supplied.
2: Specified key was not found in the file.
3: Specified file does not exist.
4: Unsupported mode recived.
5: Specified file is not plist.
6: Unknown argument recived.

About

Reads or modifies plist key values

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages