Jump to content


[C#] Command only global options

.net api global options g-opts

  • Please log in to reply
7 replies to this topic

#1 CodingMadeEasy

CodingMadeEasy

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 22 January 2016 - 07:42 PM

Hello, I was wondering if it was possible to set global options for a command, instead of setting it for the global connection. The problem with it being with the global connection is that if any of the global options needs to be modified, we'll have to close the current connection and create a new one which is something we would like to avoid. Is there a way for us to add the global options to a command?

Thanks.

#2 CodingMadeEasy

CodingMadeEasy

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 25 January 2016 - 06:43 PM

bump.

#3 mister_wilson

mister_wilson

    Advanced Member

  • Members
  • PipPipPip
  • 121 posts
  • LocationMontreal, Quebec

Posted 26 January 2016 - 04:06 PM

Hi,

I would also like to know if this is doable?

For example if I wanted to do the equivalent command using the .NET API:
p4 -v net.tcpsize=524288 sync --parallel "threads=4,min=1,minsize=1"




Server server = new Server(new ServerAddress(URI));
Repository rep = new Repository(server);
Connection conn = rep.Connection;
conn.UserName = P4USER;
		   
conn.Client = new Client();
conn.Client.Name = P4CLIENT;
conn.Connect(null);
// change the Command Time Out to 20 seconds
conn.CommandTimeout = TimeSpan.FromSeconds(20);
Credential cred = conn.Login(P4PASS, null, null);

P4Command p4Command = conn.CreateCommand("sync", true, new[] { "--parallel", "threads=4,min=1,minsize=1", "//mydepot/mybranch/..."});

P4CommandResult resultSet = p4Command.Run();

Where could I specify the global options -v net.tcpsize=524288?

Thanks,

-Jonathan

#4 CodingMadeEasy

CodingMadeEasy

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 28 January 2016 - 03:59 PM

Seriously? Is there no support here on the forums? Myself and mister_wilson have asked a simple question. Can we at least get a reply?

#5 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 28 January 2016 - 08:56 PM

View PostCodingMadeEasy, on 22 January 2016 - 07:42 PM, said:

Hello, I was wondering if it was possible to set global options for a command, instead of setting it for the global connection.

Hello Peter.  Sorry that you were not able to get a reply. If you need more speedy assistance, please contact support@perforce.com via email or chat or by phone. Support is available in several timezones and you are guaranteed a Perforce support person to handle your case.

View Postmister_wilson, on 26 January 2016 - 04:06 PM, said:

I would also like to know if this is doable?

For example if I wanted to do the equivalent command using the .NET API:
p4 -v net.tcpsize=524288 sync --parallel "threads=4,min=1,minsize=1"

Hi Jonathan, I have contacted our development team to research an answer for you. This question is not one I have found asked before but it is a good question.


To both Peter and Jonathan,

Here is what I have found out so far...

All of the "global options" (options that get passed to p4 before the command name) are handled client-side by the application, not by the server (which is what the API talks to).  Global option handling is the main difference between something like samplemain.cc and the real p4.

If you are reimplementing p4, you can use the "Options" class included in the API to make the option parsing easy.  For example, using Options to parse and handle the standard connection-related global options looks like:
		argc--;
		argv++;
		opts.Parse( argc, argv, "c:H:d:u:p:P:", OPT_SOME, eid_usage, &error );
		StrPtr* s = 0x0;
		if ( s = opts[ '!' ] ) return 0;
		if ( s = opts[ 'c' ] ) client.SetClient ( s );
		if ( s = opts[ 'H' ] ) client.SetHost ( s );
		if ( s = opts[ 'd' ] ) client.SetCwd ( s );
		if ( s = opts[ 'u' ] ) client.SetUser ( s );
		if ( s = opts[ 'p' ] ) client.SetPort ( s );
		if ( s = opts[ 'P' ] ) client.SetPassword ( s );
REFERENCES

- Options Class
https://www.perforce...ence/Index.html

- Options methods [C/C++ API User Guide (2015.2)]
https://www.perforce...ds.html#options

#6 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 29 January 2016 - 12:34 AM

Peter and Jonathan,

I have an update after speaking with development.  There is an enhancement request for the ability to set enviroment vars and global option command line flags, which I have added you both to. There are P4CONFIG and P4ENVIO but this requires the user to know about and to create these, which is far from ideal.

EXAMPLE

=>p4 set P4ENVIRO=%userprofile%\p4enviro.txt
=>p4 set net.tcpsize=512k
=>p4 set net.tcpsize
      net.tcpsize=512k (enviro)

#7 CodingMadeEasy

CodingMadeEasy

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 29 January 2016 - 03:49 PM

Thanks for the reply. What is the ETA for the enhancement?

#8 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 02 February 2016 - 07:31 PM

View PostCodingMadeEasy, on 29 January 2016 - 03:49 PM, said:

Thanks for the reply. What is the ETA for the enhancement?

You're welcome! In terms of a scheduled release, I cannot say for sure. However, checking the release notes will always update you on all the new features and fixes:

    https://www.perforce...n/release-notes

Or subscribe to the Release Notifications RSS feed or visit the Communication Center

    http://info.perforce...nication-center

to sign-up for monthly product announcements delivered by email. Also, your name and email is added to the issue and when it is implemented you will be sent an email notification.





Also tagged with one or more of these keywords: .net, api, global, options, g-opts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users