Skip to content

Improve help output with usage examples and/or response templates #238

@Adam-it

Description

@Adam-it

Description

Currently, the help output shows the:

  • usage
  • Optional arguments - BTW this is not the best name, it should be just 'Options'. For example, for the spfx create command, some of those arguments are actually not optional but required

What the help output could also provide is:

  • examples - provide from 2 to 5 (depending on the number of options the command have) usage examples for the command
  • response - provide a simple response template for each possible output mode

Use case

In general, providing examples will increase adoption, allowing the users to better understand the command and use it.
Additionally, providing examples and responses will allow LLMs and agents, to more easily understand the how to use the command. So in the future Copilot or any other AI tool will understand how to use the commands of this CLI and will make fewer mistakes

Alternatives considered

Alternatively, those information could just be provided in docs and LLM could retrieve it using fetch or context7 MCP

Additional context

IMHO a good example is the help output mode of CLI for Microsoft 365 commands.

For example

SPO SITE ADD
============

Creates new SharePoint Online site


USAGE

  m365 spo site add [options]



OPTIONS

  --type [type]
    Type of sites to add. Allowed values TeamSite, CommunicationSite, ClassicSite, default TeamSite

  -t, --title <title>
    Site title

  -a, --alias [alias]
    Site alias, used in the URL and in the team site group e-mail (applies to type TeamSite)

  -u, --url [url]
    Site URL  (applies to type CommunicationSite, ClassicSite)

  -z, --timeZone [timeZone]
    Integer representing time zone to use for the site (applies to type ClassicSite)

  -d, --description [description]
    Site description

  -l, --lcid [lcid]
    Site language in the LCID format, eg. 1033 for en-US. See SharePoint documentation (https://support.microsoft.com/en-us/office/languages-supported-by-sharepoint-dfbf3652-2902-4809-be21-9080b6512fff) for the list of supported languages

  --owners [owners]
    Comma-separated list of users to set as site owners (applies to type TeamSite, ClassicSite)

  --isPublic
    Determines if the associated group is public or not (applies to type TeamSite)

  -c, --classification [classification]
    Site classification (applies to type TeamSite, CommunicationSite)

  --siteDesign [siteDesign]
    Type of communication site to create. Allowed values Topic, Showcase, Blank, default Topic. When creating a communication site, specify either siteDesign or siteDesignId (applies to type CommunicationSite)

  --siteDesignId [siteDesignId]
    Id of the custom site design to use to create the site. When creating a communication site, specify either siteDesign or siteDesignId (applies to type CommunicationSite)

  --shareByEmailEnabled
    Determines whether it's allowed to share file with guests (applies to type CommunicationSite)

  -w, --webTemplate [webTemplate]
    Template to use for creating the site. Default STS#0  (applies to type ClassicSite)

  --resourceQuota [resourceQuota]
    The quota for this site collection in Sandboxed Solutions units. Default 0  (applies to type ClassicSite)

  --resourceQuotaWarningLevel [resourceQuotaWarningLevel]
    The warning level for the resource quota. Default 0  (applies to type ClassicSite)

  --storageQuota [storageQuota]
    The storage quota for this site collection in megabytes. Default 100  (applies to type ClassicSite)

  --storageQuotaWarningLevel [storageQuotaWarningLevel]
    The warning level for the storage quota in megabytes. Default 100  (applies to type ClassicSite)

  --removeDeletedSite
    Set, to remove existing deleted site with the same URL from the Recycle Bin  (applies to type ClassicSite)

  --withAppCatalog
    Set, to create a site collection app catalog on the newly created site.

  --wait
    Wait for the site to be provisioned before completing the command  (applies to type ClassicSite)

  -h, --help [help]
    Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, permissions, response, full. Default is options.

  --query [query]
    JMESPath query string. See http://jmespath.org/ for more information and examples.

  -o, --output [output]
    Output type. json, text, csv, md, none. Default json.

  --verbose
    Runs command with verbose logging.

  --debug
    Runs command with debug logging.




REMARKS FOR CLASSIC SITES

Using the -z, --timeZone option you have to specify the time zone of the site. For more information about the valid values see https://msdn.microsoft.com/library/microsoft.sharepoint.spregionalsettings.timezones.aspx.

The value of the --resourceQuota option must not exceed the company's aggregate available Sandboxed Solutions quota. For more information, see Resource Usage Limits on Sandboxed Solutions in SharePoint 2010: http://msdn.microsoft.com/en-us/library/gg615462.aspx.

The value of the --resourceQuotaWarningLevel option must not exceed the value of the --resourceQuota option.

The value of the --storageQuota option must not exceed the company's available quota.

The value of the --storageQuotaWarningLevel option must not exceed the the value of the --storageQuota option.

If you try to create a site with the same URL as a site that has been previously moved to the recycle bin, you will get an error. To avoid this error, you can use the --removeDeletedSite option. Prior to creating the site, the spo site add command will check if the site with the specified URL has been previously moved to the recycle bin and if so, will remove it. Because removing sites from the recycle bin might take a moment, it should be used in conjunction with the --wait option so that the new site is not created before the old site is fully removed.

Deleting and creating classic site collections is by default asynchronous and depending on the current state of Office 365, might take up to few minutes. If you're building a script with steps that require the site to be fully provisioned, you should use the --wait flag. When using this flag, the spo site add command will keep running until it received confirmation from Office 365 that the site has been fully provisioned.


REMARKS FOR MODERN SITES

The --owners option is mandatory for creating CommunicationSite sites with app-only permissions.

When trying to create a team site using app-only permissions, you will get an Insufficient privileges to complete the operation. error. As a workaround, you can use the entra m365group add command, followed by spo site set to further configure the Team site.


EXAMPLES

Create modern team site with private group

  m365 spo site add --alias team1 --title "Team 1"


Create modern team site with description and classification

  m365 spo site add --type TeamSite --alias team1 --title "Team 1" --description "Site of team 1" --classification LBI


Create modern team site with public group

  m365 spo site add --type TeamSite --alias team1 --title "Team 1" --isPublic


Create modern team site using the Dutch language

  m365 spo site add --alias team1 --title "Team 1" --lcid 1043


Create modern team site with the specified users as owners

  m365 spo site add --alias team1 --title "Team 1" --owners "steve@contoso.com, bob@contoso.com"


Create a modern team site and enable the site collection app catalog

  m365 spo site add --alias team1 --title "Team 1" --withAppCatalog


Create communication site using the Topic design

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing


Create communication site using app-only permissions

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing --owners "john.smith@contoso.com"


Create communication site using the Showcase design

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing --siteDesign Showcase


Create communication site using a custom site design

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing --siteDesignId 99f410fe-dd79-4b9d-8531-f2270c9c621c


Create communication site using the Blank design with description and classification

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing --description Site of the marketing department --classification MBI --siteDesign Blank


Create a communication site and enable the site collection app catalog

  m365 spo site add --type CommunicationSite --url https://contoso.sharepoint.com/sites/marketing --title Marketing --withAppCatalog


Create a new classic site collection using the Team site template. Set time zone to UTC+01:00. Don't wait for the site provisioning to complete

  m365 spo site add --type ClassicSite --url https://contoso.sharepoint.com/sites/team --title Team --owners admin@contoso.onmicrosoft.com --timeZone 4


Create a new classic site collection using the Team site template. Set time zone to UTC+01:00. Wait for the site provisioning to complete

  m365 spo site add --type ClassicSite --url https://contoso.sharepoint.com/sites/team --title Team --owners admin@contoso.onmicrosoft.com --timeZone 4 --webTemplate STS#0 --wait


Create a new classic site collection using the Team site template. Set time zone to UTC+01:00. If a site with the same URL is in the recycle bin, delete it. Wait for the site provisioning to complete

  m365 spo site add --type ClassicSite --url https://contoso.sharepoint.com/sites/team --title Team --owners admin@contoso.onmicrosoft.com --timeZone 4 --webTemplate STS#0 --removeDeletedSite --wait


Create a new classic site and enable the site collection app catalog

  m365 spo site add --type ClassicSite --url https://contoso.sharepoint.com/sites/team --title Team --owners admin@contoso.onmicrosoft.com --timeZone 4 --webTemplate STS#0 --withAppCatalog



RESPONSE
  JSON

  "https://contoso.sharepoint.com/sites/marketing"

  Text

  https://contoso.sharepoint.com/sites/marketing

  CSV

  https://contoso.sharepoint.com/sites/marketing

  Markdown

  https://contoso.sharepoint.com/sites/marketing



MORE INFORMATION

- Creating SharePoint Communication Site using REST: https://learn.microsoft.com/sharepoint/dev/apis/communication-site-creation-rest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions