-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
263 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,56 @@ | ||
# ElasticNow CLI | ||
|
||
This project was inspired by [Preston Gibbs](mailto:[email protected]) and his hate for time tracking. | ||
|
||
## Usage | ||
|
||
### Autocomplete | ||
|
||
`elasticnow --generate [possible values: bash, elvish, fish, powershell, zsh]` outputs the autocompletion that can be pushed to proper file for autocomplete. | ||
|
||
### Authentication | ||
|
||
To initialize the repo you will need to run `elasticnow setup`. This will generate a config.toml. The location is dependent on the operating system but can be found at the top of the help output. | ||
|
||
| Flag | Description | | ||
| --- | --- | | ||
| `--id <ID>` | The ElasticNow ID (retrieved from ElasticNow instance) [env: ELASTICNOW_ID] | | ||
| `--instance <INSTANCE>` | The ElasticNow instance [env: ELASTICNOW_INSTANCE=] | | ||
| `--sn-instance <SN_INSTANCE>` | The ServiceNow Instance (e.g. libertydev, liberty) [env: SN_INSTANCE=] | | ||
| `--sn-username <SN_USERNAME>` | The ServiceNow Username [env: SN_USERNAME=] | | ||
| `--sn-password <SN_PASSWORD>` | The ServiceNow Password [env: SN_PASSWORD] | | ||
| `-b, --bin <BIN>` | Override default bin for searching (defaults to user's assigned bin) | | ||
| `-h, --help` | Print help | | ||
| Flag | Description | | ||
| ----------------------------- | --------------------------------------------------------------------------- | | ||
| `--id <ID>` | The ElasticNow ID (retrieved from ElasticNow instance) [env: ELASTICNOW_ID] | | ||
| `--instance <INSTANCE>` | The ElasticNow instance [env: ELASTICNOW_INSTANCE=] | | ||
| `--sn-instance <SN_INSTANCE>` | The ServiceNow Instance (e.g. libertydev, liberty) [env: SN_INSTANCE=] | | ||
| `--sn-username <SN_USERNAME>` | The ServiceNow Username [env: SN_USERNAME=] | | ||
| `--sn-password <SN_PASSWORD>` | The ServiceNow Password [env: SN_PASSWORD] | | ||
| `-b, --bin <BIN>` | Override default bin for searching (defaults to user's assigned bin) | | ||
| `-h, --help` | Print help | | ||
|
||
Usage: `elasticnow setup [OPTIONS] --id <ID> --instance <INSTANCE> --sn-instance <SN_INSTANCE> --sn-username <SN_USERNAME> --sn-password <SN_PASSWORD>` | ||
|
||
### Time Tracking | ||
|
||
Time tracking is dependent on the initial setup. You can use the search flag to search for an existing ticket in your bin (override with --bin), or create a new ticket. | ||
|
||
When searching, the CLI will return a list for the user to choose from after querying all active tickets in the bin matching the search key words. | ||
|
||
| Flag | Description | | ||
| ----------------------------- | --------------------------------------------------------------------------------------------------- | | ||
| `-n, --new` | Creates a new ticket instead of updating an existing one ( cannot be used with `--search` ) | | ||
| `-c, --comment <COMMENT>` | Comment for time tracking | | ||
| `--time-worked <TIME_WORKED>` | Add time in the format of 1h1m where 1 can be replaced with any number (hours must be less than 24) | | ||
| `-s, --search <SEARCH>` | Keyword search using ElasticNow (returns all tickets in bin by default) | | ||
| `-b, --bin <BIN>` | Override default bin for searching (defaults to user's assigned bin or override in config.toml) | | ||
| `-h, --help` | Print help | | ||
|
||
Usage: `elasticnow timetrack [OPTIONS] --comment <COMMENT> --time-worked <TIME_WORKED> --search <SEARCH>` | ||
|
||
### Standard Changes | ||
|
||
This just uses the ServiceNow API to query STD CHG templates and prompt the user for correct one. Alternatively, provide the sys_id of the template to avoid being prompted. | ||
|
||
Options: | ||
| Flag | Description | | ||
| --- | --- | | ||
| `-n, --new` | Creates a new ticket instead of updating an existing one ( cannot be used with `--search` ) | | ||
| `-c, --comment <COMMENT>` | Comment for time tracking | | ||
| `--time-worked <TIME_WORKED>` | Add time in the format of 1h1m where 1 can be replaced with any number (hours must be less than 24) | | ||
| `-s, --search <SEARCH>` | Keyword search using ElasticNow (returns all tickets in bin by default) | | ||
| `-b, --bin <BIN>` | Override default bin for searching (defaults to user's assigned bin or override in config.toml) | | ||
| `-s, --search <SEARCH>` | Search for a STD CHG template to create the CHG with | | ||
| `-b, --bin <BIN>` | Override default assignment group when creating the CHG | | ||
| `-t, --template-id <TEMPLATE_ID>` | Use a known template ID to skip the prompt | | ||
| `-h, --help` | Print help | | ||
|
||
Usage: `elasticnow timetrack [OPTIONS] --comment <COMMENT> --time-worked <TIME_WORKED> --search <SEARCH>` | ||
Usage: `elasticnow std-chg [OPTIONS]` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod elasticnow; | ||
pub mod servicenow; | ||
pub mod servicenow_structs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct SNResult<T = ServiceNowResultResponse> { | ||
pub result: T, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[serde(untagged)] | ||
pub enum ServiceNowResultResponse { | ||
User(Vec<UserGroupResult>), | ||
SysId(SysIdResult), | ||
SysIds(Vec<SysIdResult>), | ||
CHG(CHGCreation), | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct SysIdResult { | ||
pub sys_id: String, | ||
pub sys_name: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
pub struct UserGroupResult { | ||
#[serde(rename = "u_default_group")] | ||
pub default_group: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct TicketCreation { | ||
#[serde(rename = "assignment_group")] | ||
pub assignment_group: String, | ||
#[serde(rename = "short_description")] | ||
pub short_description: String, | ||
#[serde(rename = "description")] | ||
pub description: String, | ||
#[serde(rename = "cmdb_ci", skip_serializing_if = "Option::is_none")] | ||
pub configuration_item: Option<String>, | ||
#[serde(rename = "sys_class_name", skip_serializing_if = "Option::is_none")] | ||
pub type_: Option<String>, | ||
#[serde(rename = "priority", skip_serializing_if = "Option::is_none")] | ||
pub priority: Option<String>, | ||
#[serde(rename = "cat_item", skip_serializing_if = "Option::is_none")] | ||
pub item: Option<String>, | ||
#[serde(rename = "u_sla_type", skip_serializing_if = "Option::is_none")] | ||
pub sla_type: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct CHGCreation { | ||
pub sys_id: DisplayAndValue, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct DisplayAndValue { | ||
pub display_value: String, | ||
pub value: String, | ||
} |
Oops, something went wrong.