Files
GoogleDriveManagement/docs/Command-Line-Parsing.md
Ross Scroggs caddda2b1c
Some checks failed
Build and test GAM / build (Win64, build, 7, VC-WIN64A, windows-2022) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 2, linux-aarch64, [self-hosted linux arm64]) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 4, linux-aarch64, [self-hosted linux arm64], yes) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 6, darwin64-arm64, macos-14) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 1, linux-x86_64, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 3, linux-x86_64, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 5, darwin64-x86_64, macos-13) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 8, ubuntu-24.04, 3.13) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 9, ubuntu-24.04, 3.9) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Check for Google Root CA Updates / check-apis (push) Has been cancelled
Build and test GAM / merge (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
Integrate Wikis - Step 1
2024-10-06 09:02:31 -07:00

3.3 KiB

!# Command Line Parsing

Linux and MacOS

When entering gam csv commands, you should enclose references to CSV file headers in "; e.g., name "~name".

In bash, if an argument contains a ~, |, >, or <, you must enclose the argument in "; e.g., name "Test|Group".

In zsh, if an argument contains a ~, |, !, >, or <, you must enclose the argument in '; e.g., name 'Test|Group'.

To embed a ' in a string enclosed in ", enter '; name "Test'Group".

To embed a " in a string enclosed in ', enter "; name 'Test"Group'.

To embed a ' in a string enclosed in ', enter '\''; name 'Test'\''Group'.

To embed a " in a string enclosed in ", enter \"; name "Test\"Group".

Linux and MacOS do not recognize smart or curly quotes, and , they can not be used to enclose arguments.

Windows Command Prompt

Command Prompt does not recognize smart or curly quotes, and , they can not be used to enclose arguments.

Command Prompt does not recognize single quotes, ', they can not be used to enclose arguments.

To embed a ' in a string enclosed in ", enter '; name "Test'Group".

To embed a " in a string enclosed in ", enter \"; name "Test\"Group".

Windows PowerShell

In PowerShell, if you want an empty string argument, you must enter: `"`"

PowerShell does not recognize smart or curly quotes, and , they can not be used to enclose arguments.

To embed a ' in a string enclosed in ", enter '; name "Test'Group".

To embed a " in a string enclosed in ", enter `"; name "Test`"Group".

To embed a ' in a string enclosed in ', enter ''; name 'Test''Group'.

To embed a " in a string enclosed in ', enter \"; name 'Test\"Group'.

List quoting rules

Items in a list can be separated by commas or spaces; if an item itself contains a comma, a space or a single quote, special quoting must be used. Typically, you will enclose the entire list in double quotes and quote each item in the list as detailed below.

  • Items, separated by commas, without spaces, commas or single quotes in the items themselves
    • "item,item,item"
  • Items, separated by spaces, without spaces, commas or single quotes in the items themselves
    • "item item item"
  • Items, separated by commas, with spaces, commas or single quotes in the items themselves
    • "'it em','it,em',\"it'em\""
  • Items, separated by spaces, with spaces, commas or single quotes in the items themselves
    • "'it em' 'it,em' \"it'em\""

Typical places where these rules apply are lists of OUs and Contact Groups.

Queries example

Linux and MacOS

gam print users queries "\"orgUnitPath='/Students/Lower School/2027'\",\"orgUnitPath='/Students/Lower School/2028'\""

Windows Command Prompt

gam print users queries "\"orgUnitPath='/Students/Lower School/2027'\",\"orgUnitPath='/Students/Lower School/2028'\""

Windows Power Shell

gam print users queries "`"orgUnitPath=\'/Students/Lower\ School/2027\'`",`"orgUnitPath=\'/Students/Lower\ School/2028\'`""