## p4add-clientspec ## aaron bockelie <# .SYNOPSIS Creates a valid clientspec and returns it to stdout. .DESCRIPTION This function will create a clientspec formatted correctly for stdin to p4.exe given a set of minimum parameters. The required parameters 'root' and 'clientname' are all that are required to create a clientspec, however just using defaults may not be configure a usable clientspect due to the script defaults assumed. .EXAMPLE c:\p4powershell> p4add-clientspec -root c:\banana -clientname banana Clientspec 'banana' for user AaronAdmin created. .PAREMETER owner The owner of the clientspec. Optional - defaults to the user running the script. .PARAMETER Access Clientspec access type. Optional - defaults to the datetime that script was run. .PARAMETER LineEnd Clientspec line end type. Optional - defaults to 'local' .PARAMETER SubmitOptions Clientspec submit options. Optional - defaults to 'submitunchanged' .PARAMETER Hostname Clientspec authorized hostname. Optional - defaults to hostname of workstation script was called from. .PARAMETER Root Clientspec root. Required. .PARAMETER Description Clientspec description. Optional - defaults to a helpful description that the clientspec was created through automation. .PARAMETER Options Clientspec options. Optional - defaults to perforce defaults, 'noallwrite noclobber nocompress unlocked nomodtime normdir' To feed all the options, create a single variable with a string, or enclose options in quotes. For example: $options = "unlocked normdir"; -options $options .PARAMETER Update Clientspec update date. Optional - defaults to datetime that script was run. .PARAMETER clientname The name of the clientspec. Required. .PARAMETER View Clientspec view. Optional - will default to mapping entire spec and entire depot called "depot" to clientspec. When creating a desired view, feed view into an appropriate variable, formatted the same that perforce shows a clientspec view, or enclose parameter in quotes. For example: $view = "`t//depot/... //clientname/depot/...`r`n`t-//depot/foo_unit/... //clientname/depot/foo_unit/..."; -view $view #> Function p4add-clientspec {param($Owner,$Access,$LineEnd,$SubmitOptions,$Hostname,[Parameter(Mandatory=$true)]$Root,$Description,$Options,$Update,[Parameter(Mandatory=$true)]$Clientname,[array]$View) $datefield = (get-date).year.tostring() + "`/" + (get-date).month.tostring() + "`/" + (get-date).day.tostring() + " " + (get-date).hour.tostring() + ":" + (get-date).Minute.tostring() + ":" + (get-date).second.tostring() #format date string to exactly what perforce wants #([datetime]"1/1/1970").AddSeconds($Update) if ($Owner -eq $null) { $Owner = $env:username #default username to current user if none defined. } if ($Access -eq $null) { $Access = $datefield #add default date if none defined } if ($LineEnd -eq $null) { $LineEnd = "local" #set lineend to local (perforce depot) if not set } if ($SubmitOptions -eq $null) { $SubmitOptions = "submitunchanged" #set submitoptions to perforce default if not set } if ($Hostname -eq $null) { $Hostname = $env:computername.tolower() #set hostname to workstation where the function ran, if not defined. } if ($Description -eq $null) { $Description = "Clientspec created by p4add-clientspec on " + $datefield + " by user " + $env:username #set a useful description, if description not defined. } if ($Options -eq $null) { $Options = "noallwrite noclobber nocompress unlocked nomodtime normdir" #add default options if none were defined. } if ($Update -eq $null) { $update = $datefield #add default date if none defined } if ($view -eq $null) { $View = "`t//spec/... //" + $clientname + "/spec/...`r`n`t//depot/... //" + $clientname + "/depot/..." } $spec = "`r`nClient:`t" + $Clientname + "`r`n`r`nOwner:`t" + $Owner + "`r`n`r`nHost:`t" + $Hostname + "`r`n`r`nDescription:`r`n`t" + $Description + "`r`n`r`nRoot:`t" + $Root + "`r`n`r`nOptions:`t" + $Options + "`r`n`r`nSubmitOptions:`t" + $SubmitOptions + "`r`n`r`nLineEnd:`r`n`t" + $LineEnd + "`r`n`r`nView:`r`n`t" + $View #create a group issue command in a format that perforce can digest. return $spec }#end function p4add-clientspec
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 8410 | Aaron Bockelie |
Root checkin, Perforce Powershell wrapper. Still lots of work to be done, namely documentation and deployment tools, for instance, get-help needs work on the majority of these tools. Additionally, the /lib structure needs a little bit of condensation, probably into major groups (depot, userspec, clientspec, group management, and so on) that way function family can exist under each resource. |