Stepper motor setting final position manually

hello ,
i'm new to arduino programming , under initialisation stage "i want set the final position of stepper motor by rotating it manually & store the value of the final position .

&
in run stage when ever a command is sent to the microcontroller to rotate a motor i want it to move to the set final position & stop there until a second command is sent to return to its initial position of '0'.
can someone help me with this?

You need an encoder having at least the resolution of the steppers amount of steps per revolution.
Use example codes for stepper motors. Use example code for encoders. Use example code for buttons.
When You know how to handle those devices You can start making the final code, step by step.