Skip to content

Commit

Permalink
Let API determine default name for new untitled files
Browse files Browse the repository at this point in the history
fixes #370
  • Loading branch information
FISHMANPET committed Mar 29, 2022
1 parent 9caf2fc commit 2899b66
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion PSGSuite/Public/Docs/New-GSDocument.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function New-GSDocument {
(
[parameter(Mandatory = $false,ValueFromPipeline = $true,Position = 0)]
[String]
$Title = "Untitled document",
$Title,
[parameter(Mandatory = $false)]
[Alias('Owner','PrimaryEmail','UserKey','Mail')]
[string]
Expand Down Expand Up @@ -54,6 +54,9 @@ function New-GSDocument {
try {
$body = New-Object 'Google.Apis.Docs.v1.Data.Document'
$body.Title = $Title
if (!$Title) {
$Title = "Untitled document"
}
Write-Verbose "Creating Document '$Title' for user '$User'"
$request = $service.Documents.Create($body)
$response = $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
Expand Down
5 changes: 4 additions & 1 deletion PSGSuite/Public/Sheets/New-GSSheet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function New-GSSheet {
[parameter(Mandatory = $false)]
[Alias('SheetTitle')]
[String]
$Title = "Untitled spreadsheet",
$Title,
[parameter(Mandatory = $false,ValueFromPipelineByPropertyName = $true)]
[Alias('Owner','PrimaryEmail','UserKey','Mail')]
[string]
Expand Down Expand Up @@ -55,6 +55,9 @@ function New-GSSheet {
$body.Properties = New-Object 'Google.Apis.Sheets.v4.Data.SpreadsheetProperties' -Property @{
Title = $Title
}
if (!$Title) {
$Title = "Untitled spreadsheet"
}
Write-Verbose "Creating Spreadsheet '$Title' for user '$User'"
$request = $service.Spreadsheets.Create($body)
$response = $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
Expand Down
5 changes: 4 additions & 1 deletion PSGSuite/Public/Slides/New-GSPresentation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function New-GSPresentation {
(
[parameter(Mandatory = $false,ValueFromPipeline = $true,Position = 0)]
[String]
$Title = "Untitled presentation",
$Title,
[parameter(Mandatory = $false)]
[Alias('Owner','PrimaryEmail','UserKey','Mail')]
[string]
Expand Down Expand Up @@ -54,6 +54,9 @@ function New-GSPresentation {
try {
$body = New-Object 'Google.Apis.Slides.v1.Data.Presentation'
$body.Title = $Title
if (!$Title) {
$Title = "Untitled presentation"
}
Write-Verbose "Creating Presentation '$Title' for user '$User'"
$request = $service.Presentations.Create($body)
$response = $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
Expand Down

0 comments on commit 2899b66

Please sign in to comment.