How to define custom command in .yaml file

Hello to everyone.

This is my first time releasing an app in snap, and I stock with defining a custom command for my app.

This is my snapcraft.yaml file:

name: pepe-party
version: '1.0.0'
summary: Invite pepe to your terminal!
description: |
  If you are tired of coding, invite Pepe to throw a party in your terminal.!
  To invite Pepe, run "pepe" command in your terminal!
  To quit the party either hit "Esc" or "Ctrl+C"
  Have fun:D!
  Homepage: https://github.com/shuoros/pepe-party

title: Pepe Party
website: https://github.com/shuoros/pepe-party
contact: shuoros@yahoo.com
issues: https://github.com/shuoros/pepe-party/issues
icon: ./icon.png
license: MIT

base: core18
grade: stable
confinement: strict

apps:
  pepe:
    command: bin/java -jar $SNAP/jar/pepe-party-$SNAP_VERSION-jar-with-dependecies.jar

parts:
  pepe-party:
    plugin: maven
    source: https://github.com/shuoros/pepe-party.git
    source-tag: main
    source-type: git
    maven-options: [-DskipTests]
    override-prime: |
        snapcraftctl prime
        rm -vf usr/lib/jvm/java-11-openjdk-*/lib/security/blacklisted.certs

Everything is ok. My app was uploaded to snap, and I installed it on my ubuntu. But the problem is instead of the command pepe my app runs with pepe-party.pepe. I searched a lot but I can’t find a solution. I’ll appreciate any help you can provide.

By default, a snap can define an executable with the same app name as it’s package name. For example,

Apps:
  pepe-party

Would place your executable in the system as simply pepe-party

For any other app definition where the name does not match the package name, the name is namespaced like you’re experiencing already. The user could manually run the following command if they desired.

sudo snap alias pepe-party.pepe Pepe

Alternatively, you can apply for permission from the store to automatically creates aliases on installation, of which you can see a random example I’ve picked of this process here.

If you wish to proceed with the automatic approach for the name of pepe, then feel free to create a similar post in the store-requests category. Please note in this situation, developer builds you create would still need the aliasing manually, it’s only when installed directly from the store or including a valid snap ack command that the aliasing would be fully automatic.