Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7576135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:50:58+00:00 2026-05-30T16:50:58+00:00

I have my_func.coffee file first = (test) -> console.log ‘first’ + test second =

  • 0

I have my_func.coffee file

first = (test) ->
  console.log 'first' + test

second = (test) ->
  console.log 'second' + test

How can I call ‘second’ method from command line ?
It would be nice to have something like:

coffee my_func.coffee -e "second('test')"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:50:59+00:00Added an answer on May 30, 2026 at 4:50 pm

    You are probably mixing up a couple of things here. Coffeescript is the compiler, that transforms coffeescript to javascript. The eval option to coffeescript tells it to read source code to be compiled from the command line, not to execute it.

    To execute the code, you need to run it in some kind of javascript environment. Node.js is a popular choice. So first, create your coffeescript module, call it MyMod.coffe like this:

    module = do ->
      first: (test) ->
        console.log 'first' + test
    
      second: (test) ->
        console.log 'second' + test
    
    console.log "MyMod registered", module
    
    exports.first = module.first
    exports.second = module.second
    

    There is some extra code to be able to export that code as a javascript module. Compile this using coffee -c MyMod.coffee.

    Then you can execute it from the command line with for instance:

    node -e 'var m=require("./MyMod");m.second("abcff");'
    

    and you should get this:

    MyMod registered { first: [Function], second: [Function] }
    secondabcff
    

    Updated:

    Seems you can run the coffeescript directly. If you remove the compiled MyMod.js file so you only have the MyMod.coffee lying around, you can do:

    node -e 'require("coffee-script");var m=require("./MyMod");m.second("abcff");'
    

    to get the same output. That assumes coffee-script module is installed of course.

    Update:

    You can also run the coffee executable directly:

    coffee -e 'm = require("./MyMod"); m.second("abcff")'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method: class Store < ActiveRecord::Base def my_func(str) puts str end
I have a section of code that can be summarised as follows; void MyFunc()
I have my type x of type varchar(50). How can I alter it to
I have a python function that contains an if-statement to check something. def my_func(a,
Do I have to formally define a function before I can use it as
I have the following function: def my_func(): My docstring is both funny and informative
I know how to mock methods in Python using flexmock, like flexmock(subprocess).should_receive('call').replace_with(my_func) How does
I have a program which during it's run sometimes needs to call python in
In case I have my documentation separate from my code, how do I help
This is what I have: use 5.14.0; use strict; use warnings; sub my_func(&$) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.