#!/usr/bin/env bash

# tests that "test.sh" gets mapped to "test" except when an existing task is there named "test"
assert "mise task add --file test.sh --description sh"
assert "mise task ls" "test  sh"
assert "mise task ls --json" "[
  {
    \"name\": \"test\",
    \"description\": \"sh\",
    \"source\": \"$PWD/mise-tasks/test.sh\"
  }
]"
assert "mise task ls --usage" 'cmd "test" help="sh"'

assert "mise task add --file test --description no-sh"
assert "mise task ls" "test     no-sh
test.sh  sh"
assert "mise task ls --json" "[
  {
    \"name\": \"test\",
    \"description\": \"no-sh\",
    \"source\": \"$PWD/mise-tasks/test\"
  },
  {
    \"name\": \"test.sh\",
    \"description\": \"sh\",
    \"source\": \"$PWD/mise-tasks/test.sh\"
  }
]"
assert "mise task ls --usage" 'cmd "test" help="no-sh"
cmd "test.sh" help="sh"'
