jscarle / OnePassword.NET

A 1Password CLI Wrapper for .NET.
https://jscarle.github.io/OnePassword.NET/
MIT License
23 stars 8 forks source link

Support specifying tags on CreateItem. #49

Closed VictorioBerra closed 11 months ago

VictorioBerra commented 1 year ago

As far as I can see, there is no way to set tags when creating a new item.

jscarle commented 1 year ago

According to the official CLI documentation, there's no mention that the command line options are compatible with reading a template, so I'll have to do some testing.

It all comes down to needing to adjust this line. If you have the time to do some tests with the CLI executable, it would speed up implementation of the changes.

VictorioBerra commented 1 year ago

@jscarle Can you elaborate on what you mean by reading a template?

PS C:\Program Files\1Password CLI> .\op.exe items get sample1 --vault XYZ --format json

{
  "id": "XYZ",
  "title": "Sample1",
  "tags": ["LinqPadSecret"],
  "version": 1,
  "vault": {
    "id": "XYZ",
    "name": "XYZ"
  },
  "category": "LOGIN",
  "last_edited_by": "NCHDKEDUENDZPPSWVVSFB7Y6OQ",
  "created_at": "2023-09-22T20:56:10Z",
  "updated_at": "2023-09-22T20:56:10Z",
  "additional_information": "Sample1",
  "fields": [
    {
      "id": "password",
      "type": "CONCEALED",
      "purpose": "PASSWORD",
      "label": "password",
      "value": "Sample1",
      "reference": "op://XYZ/Sample1/password",
      "password_details": {
        "strength": "TERRIBLE"
      }
    },
    {
      "id": "username",
      "type": "STRING",
      "purpose": "USERNAME",
      "label": "username",
      "value": "Sample1",
      "reference": "op://XYZ/Sample1/username"
    },
    {
      "id": "notesPlain",
      "type": "STRING",
      "purpose": "NOTES",
      "label": "notesPlain",
      "reference": "op://XYZ/Sample1/notesPlain"
    }
  ]
}
jscarle commented 1 year ago

As mentioned, the current command is:

op item create --vault {vault.Id} -

The last dash means read from stdin.

In the documentation, they use the example by piping from the result of a get template command.

op item template get Login | op item create --vault Tutorial -

What we need to figure out is when using the variation of create that uses stdin (finishing with the final dash), if its possible to use other switches like ---tags. It may be possible, it may not, the documentation doesn't make it clear. The order of options may also influence.

VictorioBerra commented 1 year ago

@jscarle Got it, I will run some tests Monday and get back to you here.

VictorioBerra commented 1 year ago

@jscarle So it looks like it did accept --title and --tags after the trailing -:

image

jscarle commented 11 months ago

Thanks for testing this for me. I'll try to get that implemented this week.

jscarle commented 11 months ago

Resolved by latest release v2.3.2.