Command line interface for SharePoint
Project description
Installation
$ pip install sharepointcli
Configuration
For general use, the spo configure
command is the fastest way to set up SharePoint CLI.
When you enter this command, the CLI prompts you for the following configurations:
- SharePoint domain
- Username
- Password
The spo configure
command stores the credentials in the credentials file.
You can configure configure multiple credentials for different SharePoint domains.
Example:
$ spo configure
SharePoint domain (e.g. example.sharepoint.com): example.sharepoint.com
Username: test@example.com
Password: *****
The credentials take precedence in the following order:
- Command line options
- Environment variables
- Credentials file
Command line options
You can use the following command line options to override the default configuration settings.
-
--username
Specifies the username.
-
--password
Specifies the password associated with the username.
-
--timeout
Specifies the timeout in seconds.
Environment variables
Environment variables provide another way to specify credentials, and can be useful for scripting. If you specify an option by using a parameter on the command line, it overrides any value from the environment variables or the configuration file.
The CLI supports the following environment variables:
-
SPO_CREDENTIALS_FILE
Specifies the location of the file that the CLI to store credentials. The default path is ~/.spo/credentials.
-
SPO_USERNAME
Specifies the username.
-
SPO_PASSWORD
Specifies the password associated with the username.
-
SPO_TIMEOUT
Specifies the timeout in seconds.
Credentials file
The CLI stores sensitive credential information in a file named credentials in a directory named .spo
in your home directory.
For example, the file generated with spo configure
looks similar to the following:
[example.sharepoint.com]
username = user@example.com
password = secret
Usage
configure
Configures credentials.
Usage
$ spo configure [domain]
cp
Copying a local file to SharePoint.
Usage
$ spo cp <LocalPath> <SharePointUrl> or cp <SharePointUrl> <LocalPath>
Examples
The following cp command copies a single file to a specified site:
$ spo cp test.txt 'https://example.sharepoint.com/sites/example/Shared documents/test.txt'
upload: test.txt to https://example.sharepoint.com/sites/example/Shared documents/test.txt
The following cp command copies a single file from a SharePoint site:
$ spo cp 'https://example.sharepoint.com/sites/example/Shared documents/test.txt' test.txt
download: https://example.sharepoint.com/sites/example/Shared documents/test.txt' to test.txt
help
Displays commands help.
Usage
$ spo help [topic]
ls
Lists files and folders.
Usage
$ spo ls [options] <SharePointUrl>
Options
-mtime n File's status was last changed n*24 hours ago. ('+n' more than n, 'n' exactly n, '-n' less than n)
Examples
$ spo ls 'https://example.sharepoint.com/sites/example/Shared documents/*.txt'
mkdir
Creates folder.
Usage
$ spo mkdir <SharePointUrl>
rm
Deletes files.
Usage
$ spo rm [options] <SharePointUrl>
Options
-mtime n File's status was last changed n*24 hours ago. ('+n' more than n, 'n' exactly n, '-n' less than n)
Examples
$ spo rm 'https://example.sharepoint.com/sites/example/Shared documents/*.txt'
rmdir
Deletes folder.
Usage
$ spo rmdir <SharePointUrl>
version
Prints the version number.
Usage
$ spo version
Tests
To run the unit tests:
- create the ~/.spo/credentials credentials file
- export your SharePoint test site url as environment variable 'SITE'
$ spo configure
SharePoint domain (e.g. example.sharepoint.com): example.sharepoint.com
Username: test@example.com
Password: *****
$ expot SITE='https://example.sharepoint.com/sites/example/Shared documents/test folder'
$ make test
License
This project is licensed under the MIT license.
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for sharepointcli-1.3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54309949740bac071358726d075c7f2482e82f02fafc4f7d4724be44bdf6fc7d |
|
MD5 | 193f6cfb83e0ce2a8c7950660170c2af |
|
BLAKE2b-256 | 3185c0e01c0b6f15155089b4cc8dd45ee7651f75d181d8f795b4222796e33485 |