Last active
March 1, 2016 16:38
-
-
Save jaderfeijo/801eb09e6ee38c143f52 to your computer and use it in GitHub Desktop.
build
This file contains hidden or 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
| #!/usr/bin/ruby | |
| require 'plist' | |
| command = ARGV[0] | |
| file_path = "Info.plist" | |
| supported_parameters = "Supported parameters: increment, decrement, print" | |
| if !File.file?(file_path) | |
| print "File '#{file_path}' not found.\n\n" | |
| exit 1 | |
| end | |
| if command == nil | |
| print "Please specify a parameter.\n\n#{supported_parameters}\n\n" | |
| exit 1 | |
| elsif command != "increment" && command != "decrement" && command != "print" | |
| print "Invalid command '#{command}'\n\n#{supported_parameters}\n\n" | |
| exit 1 | |
| end | |
| plist = Plist::parse_xml(file_path) | |
| bundle_version = plist['CFBundleVersion'].to_i | |
| if command == "increment" | |
| bundle_version += 1 | |
| elsif command == "decrement" | |
| bundle_version -= 1 | |
| end | |
| if command != "print" | |
| plist['CFBundleVersion'] = bundle_version.to_s | |
| File.open(file_path, 'w') { |file| file.write(plist.to_plist) } | |
| end | |
| print bundle_version.to_s + "\n" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment