options.h #1

  • //
  • guest/
  • alan_petersen/
  • piper/
  • mac/
  • R2.0/
  • Perforce/
  • p4api/
  • Headers/
  • options.h
  • View
  • Commits
  • Open Download .zip Download (12 KB)
/*
 * Copyright 1995, 1996 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 */

/*
 * Options::Parse() - parse command line options
 *
 *	The "opts" string list flags.  Each (single character) flag x
 *	can be followed by an optional modifier:
 *
 *		x.	- flag takes an argument (-xarg)
 *		x:	- flag takes an argument (-xarg or -x arg)
 *		x?	- flag takes an optional argument (--long=arg only)
 *		x+	- flag takes a flag and arg (-xyarg or -xy arg)
 *		x#	- flag takes a non-neg numeric arg (-xN or -x N)
 */

const int N_OPTS = 256;

enum OptFlag {
	// Bitwise selectors

	OPT_ONE = 0x01,		// exactly one
	OPT_TWO = 0x02,		// exactly two
	OPT_THREE = 0x04,	// exactly three
	OPT_MORE = 0x08,	// more than two
	OPT_NONE = 0x10,	// require none
	OPT_MAKEONE = 0x20,	// if none, make one that points to null

	// combos of the above

	OPT_OPT = 0x11,		// NONE, or ONE
	OPT_ANY = 0x1F,		// ONE, TWO, THREE, MORE, or NONE
	OPT_DEFAULT = 0x2F,	// ONE, TWO, THREE, MORE, or MAKEONE
	OPT_SOME = 0x0F		// ONE, TWO, THREE, or MORE
} ;

struct ErrorId;

class Options
{
    public:
			Options() { optc = 0; }

	enum Opt {

		// options which are used commonly, across many commands:

	                All            = 'a',
			Archive        = 'A',
	                Change         = 'c',
	                Delete         = 'd',
	                Depot          = 'D',
	                Expression     = 'e',
	                NoCaseExpr     = 'E',
	                Force          = 'f',
	                Filter         = 'F',
			Input          = 'i',
			JournalPrefix  = 'J',
	                Long           = 'l',
	                Max            = 'm',
	                Preview        = 'n',
			Output         = 'o',
			OutputFlags    = 'O',
			Port           = 'p',
			Parent         = 'P',
	                Quiet          = 'q',
	                Reverse        = 'r',
			Short          = 's',
			Stream         = 'S',
			Filetype       = 't',
			Tags           = 'T',
			User           = 'u',
	                Variable       = 'v',
	                Wipe           = 'w',
	                Compress       = 'z',

		// options which are relatively uncommon, but have existing
		// short-form versions:

			InfrequentShortFormOptions = 1000,

			Version        , // -V
			Client         , // -c client
			Shelf          , // -s shelf
			DiffFlags      , // -d<diff-flags>
			Inherited      , // -i on changes, filelog, etc.
			ClientName     , // -C client
			Charset        , // p4 -C charset
			CmdCharset     , // p4 -Q charset
			Help           , // -h for main programs
	                Batchsize      , // -b N
	                MessageType    , // 'p4 -s'
	                Xargs          , // 'p4 -x file'
			Exclusive      , // opened -x
			Directory      , // p4 -d dir
			Host           , // p4 -H host
			Password       , // -P password
			Retries        , // p4 -r retries
			Progress       , // p4 -I
			NoIgnore       , // add -I
			Downgrade      , // add -d
			Unload         , // -U for unloaded objects
			CentralUsers   , // users -c
			ReplicaUsers   , // users -r
			Branch         , // unshelve -b
			FullBranch     , // branch -F
			SpecFixStatus  , // change -s, submit -s
			ChangeType     , // change -t
			ChangeUpdate   , // change -u
			Original       , // change -O, describe -O
			ChangeUser     , // change -U
			Template       , // client -t, label -t
			Switch         , // client -s
	                Temporary      , // client -x
	                Owner          , // group -a
	                Administrator  , // group -A
	                Global         , // label/labelsync/tag -g
	                StreamType     , // stream -t
	                VirtualStream  , // stream -v
	                Brief          , // changes -L, filelog -L
	                ShowTime       , // changes -t, filelog -t
	                ChangeStatus   , // changes -s
	                Exists         , // files -e
	                Blocksize      , // sizes -b
			Shelved        , // sizes -S, describe -S
	                Summary        , // sizes -s
	                OmitLazy       , // sizes -z
	                Human1024      , // sizes -h
	                Human1000      , // sizes -H
	                LimitClient    , // list -C
	                LabelName      , // list -l
	                RunOnMaster    , // list -M
	                LeaveKeywords  , // print -k
	                OutputFile     , // print -o
	                Content        , // filelog -h
	                OmitPromoted   , // filelog -p
	                OmitMoved      , // filelog -1
			KeepClient     , // edit -k, delete -k, sync -k
			FileCharset    , // add/edit -Q
			Virtual        , // delete -v
			Generate       , // server -g
			Usage          , // license -u
			Job            , // fixes -j
			Increment      , // counter -i
			FixStatus      , // fix -s
			Replace        , // shelve -r
			ShelveOpts     , // shelve -a
			SubmitShelf    , // submit -e
			SubmitOpts     , // submit -f
			Reopen         , // submit -r
			Description    , // submit -d
			Tamper         , // submit -t
			Date           , // unload -d
			StreamName     , // unload -s, reload -s
			Unchanged      , // revert -a
			KeepHead       , // archive -h
			Purge          , // archive -p
			ForceText      , // archive -t
			BinaryAsText   , // -t on annotate, diff, diff2,
	                                 // grep, resolve, merge3, ...
			BypassFlow     , // -F on copy, interchanges, merge
			ShowChange     , // annotate -c
			FollowBranch   , // annotate -i
			FollowInteg    , // annotate -I
			SourceFile     , // -s on copy, integrate, merge,
			                 // interchanges, populate
			ResolveFlags   , // resolve -A<flags>
			AcceptFlags    , // resolve -a<flags>
			IntegFlags     , // integrate -R<flags>
			DeleteFlags    , // integrate -D<flags>
			RestrictFlags  , // fstat -R<flags>
			SortFlags      , // fstat -S<flags>
			ForceFlag      , // client -d -f -F<flags>
			UseList        , // sync -L, fstat -L
			Safe           , // sync -s
			Publish        , // sync -p
			IsGroup        , // groups -g
			IsUser         , // groups -u
			IsOwner        , // groups -o
			Verbose        , // groups -v
	                LineNumber     , // grep -n
			InvertMatch    , // grep -v
	                FilesWithMatches,// grep -l
	                FilesWithoutMatch,// grep -L
			NoMessages     , // grep -s
	                FixedStrings   , // grep -F
			BasicRegexp    , // grep -G
	                ExtendedRegexp , // grep -E
			PerlRegexp     , // grep -P
	                Regexp         , // grep -e
	                AfterContext   , // grep -A
			BeforeContext  , // grep -B
	                Context        , // grep -C
			IgnoreCase     , // grep -i
	                Repeat         , // pull -i
	                Backoff        , // pull -b
	                ArchiveData    , // pull -u
	                Status         , // pull -l
	                LocalJournal   , // pull -L
	                JournalPosition, // pull -j
	                PullServerid   , // pull -P
	                ExcludeTables  , // pull -T
	                File           , // pull -f
	                Revision       , // pull -r
	                Append         , // logappend -a, property -a
	                Sequence       , // logger -c
	                Counter        , // logger -t
	                HostName       , // login -h
	                Print          , // login -p
	                LoginStatus    , // login -s
	                StartPosition  , // logparse -s, logtail -s
	                Encoded        , // logparse -e
	                LogName        , // logtail -l
	                CompressCkp    , // p4 admin checkpoint -Z
	                SpecType       , // p4 admin updatespecdepot -s
	                MaxAccess      , // p4 protects -m
	                GroupName      , // p4 protects -g
	                ShowFiles      , // p4 interchanges -f
	                Name           , // attribute -n, property -n
	                Value          , // attribute -v, property -v
	                Propagating    , // attribute -p
	                OpenAdd        , // reconcile -a
	                OpenEdit       , // reconcile -e
	                OpenDelete     , // reconcile -d
	                UseModTime     , // reconcile -m
	                Local          , // reconcile -l
	                OutputBase     , // resolved -o
	                System         , // set -s
	                Service        , // set -S
	                Histogram      , // dbstat -h
	                TableNotUnlocked,// dbverify -U
	                TableName      , // dbverify -t
	                AllClients     , // lockstat -C
	                CheckSize      , // verify -s
	                Transfer       , // verify -t
	                Update         , // verify -u
	                Verify         , // verify -v
	                NoArchive      , // verify -X
	                Serverid       , // clients -s, labels -s
	                Unified        , // diff2 -u
	                PreviewNC      , // resolve -N
	                Estimates      , // sync -N/flush -N/update -N
	                Locked         , // unload -L
	                UnloadAll      , // unload -a
			KeepHave       , // integrate -h
			Yes            , // trust -y
			No             , // trust -n
			InputValue     , // trust -i
			Replacement    , // trust -r
			Rebuild        , // jobs -R
			Equal          , // fstat -e
			AttrPattern    , // fstat -A
			DiffListFlag   , // diff -s
			Arguments      , // monitor show -a
			Environment    , // monitor show -e
			TaskStatus     , // monitor show -s
			AllUsers       , // property -A
			Promote        , // shelve -p
			Test           , // ldap -t, ldaps -t
			Active         , // ldaps -A
			GroupMode      , // ldapsync -g
			Create         , // switch -c
			List           , // switch -l
			Mainline       , // switch -m
			MoveChanges    , // switch -r
			ReplicationStatus, // servers --replication-status, servers -J

		// options which have only long-form option names go here:

			LongFormOnlyOptions = 2000,

	                NoRejournal    , // pull --no-rejournal
	                From           , // renameuser --from
	                To             , // renameuser --to
	                Parallel       , // sync --parallel
	                ParallelSubmit , // submit --parallel
	                InputFile      , // reload --input-file
	                PidFile        , // p4d --pid-file
	                NoRetransfer   , // submit --noretransfer
	                ForceNoRetransfer, // submit --forcenoretransfer
			DurableOnly    , // journalcopy --durable-only
			NonAcknowledging, // journalcopy --non-acknowledging
			BypassExclusiveLock, // open --bypass-exclusive-lock
			RetainLbrRevisions, // unzip --retain-lbr-revisions
			JavaProtocol   , // p4d -i --java

			UnusedLastOption
	} ;

	void		Parse( int &argc, char **&argv, const char *opts, 
		    		int flag, const ErrorId &usage, Error *e );

	void		ParseLong( int &argc, char **&argv, const char *opts, 
		    		const int *longOpts,
		    		int flag, const ErrorId &usage, Error *e );

	void		Parse( int &argc, StrPtr *&argv, const char *opts, 
		    		int flag, const ErrorId &usage, Error *e );

	void		ParseLong( int &argc, StrPtr *&argv, const char *opts, 
		    		const int *longOpts,
		    		int flag, const ErrorId &usage, Error *e );

	StrPtr *	operator [](int opt) 
			{ return GetValue( opt, 0, 0 ); }

	StrPtr *	GetValue( int opt, int subopt )
			{ return GetValue( opt, 0, subopt ); }

	StrPtr *	GetValue( int opt, char flag2, int subopt );

	int		FormatOption( int i, Error *e );
	int		FormatOption( int i, StrBuf & f) const;
	int		HasOption( int i );
	void		GetOptionName( int i, StrBuf &sb );
	void		GetOptionValue( int i, StrBuf &sb );

    private:
	int 	optc;

	int	flags[ N_OPTS ];
	char	flags2[ N_OPTS ];
	StrRef	vals[ N_OPTS ];

	static struct OptionInfo {
	    const char *name;
	    int   optionCode;
	    int   shortForm;
	    int   valueType;
	    const ErrorId *help;
	} list[];
} ;

# Change User Description Committed
#1 15071 alan_petersen Populate -o //guest/perforce_software/piper/...
//guest/alan_petersen/piper/....
//guest/perforce_software/piper/mac/R2.0/Perforce/p4api/Headers/options.h
#2 13626 alan_petersen Copying using piper_mac_main2r2.0
#1 12962 alan_petersen Populate -o //guest/perforce_software/piper/mac/main/...
//guest/perforce_software/piper/mac/R2.0/....
//guest/perforce_software/piper/mac/main/Perforce/p4api/Headers/options.h
#2 12961 alan_petersen Piper 2.0 Mega Update

New Features/Functionality
- Added help menu redirecting to URL.
- Added readonly property for creating new workspaces.
- Added html hyperlinks for Copy link functionality.
- Added functionality for managing Finder Favorite items in sidebar.
- Redesigned the way mapping is stored in Piper.
- First version of syncing finder sidebar items with workspace mapping.
- Small sorting improvements.
- Creating Projects directory inside users home folder.
- Adding Projects folder to finder sidebar item.
- Creating and removing symbolic links accordingly to mapped folders.
- Preventing duplicate names in symbolic links.
- Refreshing symbolic links on mapping change inside application.
- Storing workspace and server details in p4 configuration for other applications to use.
- Added contextual menu items for Finder integration.
- Added services menu for Adobe Illustrator integration.
- Keyboard shortcuts for Illustrator integration.
- Code refactoring and fixes for mapping issues.
- Added Finder functionality to edit all files in folder.
- Added user friendly message when editing a file using Finder outside the workspace.
- Implemented hidden automatic login when opening application using Finder integration.
- Logging to file in ~/Library/Logs
- Unified workspace and all files views to show both local and depot files and folders.
- Removed my workspace view references and logic.
- Editing unmapped files on server.
- First version of adding file to unmapped folders.
- Showing opened by and edit actions in column details for all depot files.
- Improved mappings functionality.
- Enabled same feature options for mapped and unmapped folders and files.
- Redesigned from scratch mapping and unmapping procedures for adding and removing files.
- Implemented cleaning workspace using new mapping functionality. Removed debug overlay coloring.
- Automated workspace creation
- Improvements in editing files already mapped to workspace.
- Implemented deleting remote files.
- Implemented first version of move operation for remote files.
- Removing last workspace information when disconnecting from workspace using app menu.
- Implemented editing and submitting using symbolic links in project folder. New finder menu service for symbolic links Show in Piper which acts like share link functionality.
- New icons for files and folders not tracked in the filesystem.
- Improvements in showing file using share link.
- Switched to new way of retrieving files in order to show user changes.
- Redesigned and implemented new functionality for chaining operations with mapping.
- Improvements and redesign of Edit/add actions to use new chaining logic . Fixed issue with file edit.
- Improvements in window showing when using services.
- Simplified file loading so the local files appears only when remote are also loaded.
- Improved deleting of untracked files to avoid mapping and marking for delete.
- Enabling simple copy paste and moving of remote and local files.
- Added abort for exception handling in order to force crashing application on critical failures
- Added custom exception handling for catching runtime errors to log and crash instead of continuing in unstable state.
- Changed file copying to use mark for add .
- Simplified and fixed responding file representations to mapping changes.

Bug Fixes
- Fixed crash when synchronizing.
- Fixed sync issue when downloading directory without file size information.
- Fixed issue with unread list crashing when file is not existing on disk.
- Fixed incorrect sync progress calculation.
- Removed relative path issues.
- Fixed many of case-sensitivity problems.
- Fixed deprecated methods and related issues in OS X 10.10.
- Fixed folder rename not updating in column view. Revised and fixed many potential problems from implicit casting.
- Fixed missing sync button on fast sync completion.
- Refreshing mapping on synchronization. Fixed symbolic links not appearing until app is restarted.
- Fixed latest crashing of autosync.
- Fixed loading indicator issues.
- Fixed and redesigned submit dialog to work correctly with Submit All Files option in Finder.
- Fixed multiple error messages on network outage. Redesigned showing errors in main window.
- Fixed opening random locations when using Finder integration.
- Fixed issue when panel was detached from parent window.
- Fixed bug when creating new workspace wouldn't store default settings.
- Fixed memory issues with network operations.
- Fixes in relogging mappings and file listing.
- Improvements in editing unmapped files.
- Fixed crash when adding file outside workspace.
- Fixed breadcrumbs control issue.
- Fixed issue with double parent folders when opening unmapped files.
- Fixed crashes on sync after mapping new files.
- Fixed issue with editing file using Finder
-- Merging code and additional fixes in add button functionality.
- Fixed unsync not working
- Fixed submit panel issue not selecting files with different name case.
- Fixed missing revert and sync to workspace actions in some cases.
- Fixed issue with Submit and Edit finder actions. Improvements in stability of finder integration.
- Fixed issue with unsubmitted folders breaking status of files inside.
- Fixed issue with added files not showing correct icon and status.
- Fixed bug with file edit resulting in a new directory named exactly like a file.
- Fixed issue with reloading of subpath resulting in untracked folders.
- Fixed mapping issue when result was always view mapping not relative.
- Fixed submit panel showing more than once.
- Fixed illustrator services not working.
- Fixed userdefaults preferences problem with workspace name being null.
- Fixed userdefaults keypath problem of dot-containing workspace names.
- Forcing recreating of browser to possibly prevent pre-10.10 errors with automatic workspace selection.
- Fixed adding file to depot not presenting correct icon.
- Fixed issues with reverting a file that was marked for add.
- Presenting error when trying to submit untracked files.
- Fixed issue when submit files service crashed when using unmapped files.
- Fixed file representation disappearing when removing file.
- Fixed issue with symlinks resolving working on 10.10 only. Issue related to workspace selection not showing.
- Fixed error panel method calls unavailable in Mac OS versions before 10.10. Issue related to hanging error panels.
- Fixed removing a local file resulting in action progress freezing.
- Fixed open file not working after edit.
- Fixing crash when mapping changed. Issue related to moving local file to unmapped folder and other similar cases.
#1 11252 alan_petersen Rename/move file(s)
//guest/perforce_software/piper/mac/Perforce/p4api/Headers/options.h
#1 10744 alan_petersen Rename/move file(s)
//guest/perforce_software/piper/Perforce/p4api/Headers/options.h
#1 8919 Matt Attaway Initial add of Piper, a lightweight Perforce client for artists and designers.