Skip to content
A remote CLI tool for Mattermost
Go Makefile
Branch: master
Clone or download
anidok and grundleborg [GH-13459] Add unit tests to the "ArchiveChannelsCmd" mmctl command (#97
)

* Add tests for ArchiveChannelsCmd

* Address PR comments
Latest commit 67af279 Jan 23, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci [MM-21705] Make sure docs are updated (#104) Jan 16, 2020
client Added license header to all the .go files (#101) Jan 10, 2020
commands [GH-13459] Add unit tests to the "ArchiveChannelsCmd" mmctl command (#97 Jan 23, 2020
docs Some changes suggested to improve consistency (#108) Jan 21, 2020
mocks Added license header to all the .go files (#101) Jan 10, 2020
printer Added license header to all the .go files (#101) Jan 10, 2020
vendor Upgrade to v5 (#64) Dec 5, 2019
.gitignore
Makefile Added tFatal and equalLenAsserts checkers (#109) Jan 22, 2020
README.md Bump minimum Go version required (#98) Jan 9, 2020
go.mod Upgrade to v5 (#64) Dec 5, 2019
go.sum Upgrade to v5 (#64) Dec 5, 2019
magefile.go Added license header to all the .go files (#101) Jan 10, 2020
mmctl.go Added license header to all the .go files (#101) Jan 10, 2020

README.md

mmctl CircleCI branch Go Report Card

A remote CLI tool for Mattermost: the Open Source, self-hosted Slack-alternative.

Install

To install the project in your $GOPATH, simply run:

go get -u github.com/mattermost/mmctl

Install shell completions

To install the shell completions for bash, add the following line to your ~/.bashrc or ~/.profile file:

source <(mmctl completion bash)

For zsh, add the following line to file ~/.zshrc:

source <(mmctl completion zsh)

Compile

First we have to install the dependencies of the project. mmctl depends on go version 1.13.3 or greater.

We can compile the binary with:

make build

Running the tests

mmctl has two types of tests: unit tests and end to end tests.

To run the unit tests, you just need to execute:

make test

To run the end to end test suite, you need to have a Mattermost server instance running. Check the Developer Setup guide on how to configure a local test server instance.

Once the development server is set up, from the mattermost-server directory:

  • Start it with make run. To confirm that the instance is running correctly, you can access the web interface going to http://localhost:8065
  • Run make test-data to preload your server instance with initial seed data. Generated data such as users are typically used for logging, etc.

Change your directory to mmctl and run the end to end test suite with:

make test-e2e

Usage

For the usage of all the commands, use the --help flag or check the tool's documentation.

Mattermost offers workplace messaging across web, PC and phones with archiving, search and integration with your existing systems. Documentation available at https://docs.mattermost.com

Usage:
  mmctl [command]

Available Commands:
  auth        Manages the credentials of the remote Mattermost instances
  channel     Management of channels
  completion  Generates autocompletion scripts for bash and zsh
  group       Management of groups
  help        Help about any command
  license     Licensing commands
  logs        Display logs in a human-readable format
  permissions Management of permissions and roles
  plugin      Management of plugins
  post        Management of posts
  team        Management of teams
  user        Management of users
  websocket   Display websocket in a human-readable format

Flags:
  -h, --help   help for mmctl

Use "mmctl [command] --help" for more information about a command.

First we have to log into a mattermost instance:

$ mmctl auth login https://my-instance.example.com --name my-instance --username john.doe --password mysupersecret

  credentials for my-instance: john.doe@https://my-instance.example.com stored

We can check the currently stored credentials with:

$ mmctl auth list

    | Active |        Name | Username |                     InstanceUrl |
    |--------|-------------|----------|---------------------------------|
    |      * | my-instance | john.doe | https://my-instance.example.com |

And now we can run commands normally:

$ mmctl user search john.doe
id: qykfw3t933y38k57ubct77iu9c
username: john.doe
nickname:
position:
first_name: John
last_name: Doe
email: john.doe@example.com
auth_service:

Login methods

Password

$ mmctl auth login https://community.mattermost.com --name community --username my-username --password mysupersecret

The login command can also work interactively, so if you leave any needed flag empty, mmctl will ask you for it interactively:

$ mmctl auth login https://community.mattermost.com
Connection name: community
Username: my-username
Password:

MFA

If you want to login with MFA, you just need to use the --mfa-token flag:

$ mmctl auth login https://community.mattermost.com --name community --username my-username --password mysupersecret --mfa-token 123456

Access tokens

Instead of using username and password to log in, you can generate and use a personal access token to authenticate with a server:

$ mmctl auth login https://community.mattermost.com --name community --access-token MY_ACCESS_TOKEN
You can’t perform that action at this time.