When you are writing in code (as opposed to text), you want to stay with the names of the actions; here, it’s ‘taking’ (as opposed to ‘getting’ which is a synonym that the player can use). Also, it looks like you have created an action, perhaps called ‘taking it with’?
Taking it with is an action applying to one visible thing and one carried thing. Understand "take [something] with [something]" or "get [something] with [something]" as taking it with.
Instead of taking the apple when the apple is not handled:
if the player is not on the barrel:
say "Looking up, you realize that the apple is way too high to reach.";
say "You reach up, realizing that you are still not quite high enough to reach the apple."
This covers creating the ‘taking it with’ action, and the player trying to get the apple without the aid of the rake. With the rake, I’d use a check rule–
Check taking the apple with something when the apple is not handled:
if the player is not on the barrel:
instead say "You reach up with [the second noun], but realize that you can barely touch the apple with it. Maybe you should be standing on something?";
if the second noun is not the rake:
instead say "From your superior position on the barrel, you reach up with [the second noun], but realize that it's not quite long enough to reach the apple. Shucks."
Instead rules completely reconstruct an action–this is often not what you want, if you want the action to succeed at some point. I used ‘when the apple is not handled’ above, because that is a condition that exists before the apple is first taken, and your ‘taking it with’ action will ideally change this condition. The Check rule above ensures that the apple will not be taken unless two conditions are met–the player is on the barrel, and the player ‘takes the apple with the rake’ and only the rake; any other object would fail, unless you create other objects that can do the same thing. Now we can move on to an After rule–because now you are on the barrel, and you intend to take the apple with the rake–
After taking the apple with the rake:
if the apple was not handled:
say "Good gosh, the rake is just long enough to clip the apple, which falls to the ground with a thunk! You are so excited that you jump off the barrel, land on your tuckus, and snatch the apple out of the grass! Zounds![paragraph break]You get back on your feet, dusting yourself off.";
move the player to the location without printing a room description;
now the apple is carried by the player;
say "You manage to scoop the apple up with the rake, taking it in your hands. A miracle of modern technology.";
now the apple is carried by the player.
I use ‘was’ rather than ‘is’ (if the apple was not handled), because here, we’re assuming that the attempt passed all checks and has succeeded; now we are creating the results. We need to cover both the first successful attempt and every other attempt to take the apple with the rake, when it is no longer on the tree. ‘Move the player to the location without printing a room description’ will put the player back on the ground, and you will not see a pesky room description re-printed. And finally, ‘now the apple is carried by the player’ gives the apple to the player. You don’t want to use ‘enclosed by the player’, because that is only used in an ‘if’ clause–‘enclosed’ can mean ‘carried’, ‘worn’, ‘is a part of’, ‘on’, ‘in’, ‘inside of something carried by the player’, etc etc. When you are giving instructions to the computer in code, you want to be specific–‘now the apple is carried by the player’ puts the thing directly in the player’s hands.
I hope that this was more helpful than confusing!